I am sending a message to a web api call every xx seconds. I could not get it to work at all until I changed the header from HTTP 1.1 which is what I was using to HTTP 1.0. Then, it started working. Why would this affect things where I could not post and now I can?

This is what it was when it wasn't working:

client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.1");

And the change that fixed it:

client.println("POST /BoxLevel/api/BoxMeasurement HTTP/1.0");


1 Answer 1


HTTP/1.1 requires you to provide the host name of the server. And it will keep the connection open for some time unless you explicitly opt out of this. Thus, the equivalent of the basic HTTP/1.0 request in HTTP/1.1 language is

POST /the_uri HTTP/1.1
Host: foo.example.com
Connection: close
  • Thank you for the answer. One follow up question, with the host requirement in 1.1, does the host have to be valid? Meaning, will the client try to resolve the connection or check the host or can you populate it with anything? Jun 20, 2017 at 15:52
  • @MichaelBedford: It's up to the server to interpret the Host header. It is very common for a single server to serve more than one Web site (it's called shared hosting). The Host header is then used by the server to know which Web site the client wants. If you provide an empty or a dummy name, you usually get a useless dummy page. A server serving a single site may just ignore that header, but it could also give an error if it's incorrect. Jun 20, 2017 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.