Weird that #curl doesn't have an option for just sending arbitrary binary post data... even with `--data-binary`, curl adds a Content-Type: application/x-www-form-urlencoded header. This tripped me up just now, as this server I'm working against handles URL-encoded requests very differently from non-URL-encoded requests.
You can add `-H 'Content-Type:'` to remove the header, but it's weird that curl just adds that header even when it has no reason to think the payload is URL-encoded... #web
daniel:// stenberg://
in reply to mort • • •mort
in reply to daniel:// stenberg:// • • •@bagder Yeah, I've used curl for many years to POST data to servers and it hasn't been an issue. However, this time I was making a server using a web server library which automatically parses the body itself instead of running my body handler callback if the Content-Type is application/x-www-urlencoded >_>
Took a while to debug, I was certain I'd used the library wrong. I hadn't imagined that curl would send a bogus Content-Type (nor did I expect the library to ignore my callback to be fair)
daniel:// stenberg://
in reply to mort • • •mort
in reply to daniel:// stenberg:// • • •@bagder Curl is working as documented, of course, but the request that gets sent absolutely has a bogus Content-Type header, since the payload isn't URL encoded form data.
I don't think there's a misunderstanding anywhere. The source code spells it out (relatively) plainly: https://github.com/esphome/ESPAsyncWebServer/blob/f2a65ff6e7efa614fc50e4aa2a0fa676dda59378/src/WebRequest.cpp#L146-L147 if the Content-Type is form-urlencoded, _isPlainPost is set to true, and https://github.com/esphome/ESPAsyncWebServer/blob/f2a65ff6e7efa614fc50e4aa2a0fa676dda59378/src/WebRequest.cpp#L156-L159 the body handler only runs if _isPlainPost is set to false.