Skip to main content


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

#web #curl
in reply to mort

you can still send arbitrary data. Many servers won't even care about what the content-type header says...
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)

in reply to mort

it's not bogus since it is documented and curl has been doing this for 25 years. Also, if you think it "ignored" a callback, I suspect there's another misunderstanding in there...
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.