Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem when action request doesn't have Content-Length header
04-07-2013, 08:32 AM
Post: #11
RE: Problem when action request doesn't have Content-Length header
(04-07-2013 08:12 AM)simonc Wrote:  Thanks for doing this. I agree that it isn't valid for a HTTP/1.1 client to send a request without either a Content-Length: or Transfer-Encoding: Chunked header. I think it is still valid for a HTTP/1.0 client to connect to ohNet's 1.1 server and do this however (rfc2616 covers HTTP/1.1 only).

Unfortunately, this isn't correct. I have checked the HTTP 1.0 specification (this document), and section 7.2 of says:

An entity body is included with a request message only when the request method calls for one. The presence of an entity body in a request is signaled by the inclusion of a Content-Length header field in the request message headers. HTTP/1.0 requests containing an entity body must include a valid Content-Length header field.

This means that the device code that sends event NOTIFY messages to HTTP 1.0 control points needs to be changed to include a Content-Length header. If you are OK with this change, I will work on producing a patch.

Also, section 7.2.2 of the same document says:

Closing the connection cannot be used to indicate the end of a request body, since it leaves no possibility for the server to send back a response. Therefore, HTTP/1.0 requests containing an entity body must include a valid Content-Length header field. If a request contains an entity body and Content-Length is not specified, and the server does not recognize or cannot calculate the length from other fields, then the server should send a 400 (bad request) response.

This means that an ohNet device should not accept a POST request without a Content-Length header from an HTTP 1.0 control point, but should send a 400 Bad Request response.

Quote:Oh, and the original bug noted in this thread should be fixed and on github now. Smile

Thanks very much! I'll look at the code later.
Find all posts by this user


Messages In This Thread
RE: Problem when action request doesn't have Content-Length header - simoncn - 04-07-2013 08:32 AM

Forum Jump: