Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

'Connection' header expects 'disconnect' instead 'close' ? #13

Closed
spdi opened this issue Feb 21, 2021 · 2 comments
Closed

'Connection' header expects 'disconnect' instead 'close' ? #13

spdi opened this issue Feb 21, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@spdi
Copy link

spdi commented Feb 21, 2021

Hi,
I'm using your library to connect to me-no-dev ESPAsyncWebServer to make a POST request with body.
I had some troubles to make it work beacuse ESPAsyncWebServer accepted only first call but second was not sent because requestState returns 1.
Reading the source code I found that the Connection header is compared to have 'disconnect' value to disconnect TCP connection. So I fixed it to 'close' string and it started to work.
As https://tools.ietf.org/html/rfc2616#page-117 Connection should have 'close' value.
Could you explain why do you use 'disconnect'?
If this is bug could you fix it?

fixed line by me:
if (connectionHdr && (strcasecmp_P(connectionHdr, PSTR("close")) == 0))

Second discovered problem is debugging received data.
Data debug does not pass buffer data length to debug macro and data Vbuf is not null terminated so I read on screen the received body response and some garbage.

BTW I like your library because it support POST and other not GET methods. Thank you very much.

@khoih-prog
Copy link
Owner

HI @spdi

Thanks for pointing out the bug. You're correct that the response must be

Connection: close

for declaring non-persistence connections per Compatibility with HTTP/1.0 Persistent Connections

Persistent connections are the default for HTTP/1.1 messages; we introduce a new keyword (Connection: close) for declaring non-persistence.

I'll correct and publish a new release to fix.


Second discovered problem is debugging received data.
Data debug does not pass buffer data length to debug macro and data Vbuf is not null terminated so I read on screen the received body response and some garbage.

I'd appreciate it if you can create a PR to save me some time to investigate the non null-terminated bug. If not, can you provide a simple code to reproduce the issue so that I can trace and fix the non null-terminated bug.

Best Regards,

@khoih-prog khoih-prog added the bug Something isn't working label Feb 22, 2021
khoih-prog added a commit that referenced this issue Feb 25, 2021
### Releases v1.1.3

1. Fix non-persistent Connection header bug. Check [**'Connection' header expects 'disconnect' instead 'close' ? #13**](#13)
2. Add ESP32-S2 support
3. Tested with [**Latest ESP32 Core 1.0.5**](https://github.com/espressif/arduino-esp32) for ESP32-based boards.
@khoih-prog
Copy link
Owner

New release to fix non-persistent Connection header bug


Releases v1.1.3

  1. Fix non-persistent Connection header bug. Check 'Connection' header expects 'disconnect' instead 'close' ? #13
  2. Add ESP32-S2 support
  3. Tested with Latest ESP32 Core 1.0.5 for ESP32-based boards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants