Is a HTTP response Header (like the one below) legal even if if does not contain Content-Length or Transfer-Encoding?
- Http: Response, HTTP/1.1, Status: Ok, URL: /AAA/B.json
ProtocolVersion: HTTP/1.1
StatusCode: 200, Ok
Reason: OK
Expires: Fri, 05 Oct 2012 01:41:30 GMT
Date: Fri, 05 Oct 2012 01:40:46 GMT
Vary: Accept-Encoding
Accept-Ranges: bytes
Cache-Control: public, max-age=43
Server: Noelios-Restlet-Engine/1.1.10
ContentType: application/json;charset=UTF-8
ContentEncoding: gzip
Connection: close
X-Served-By: 85.111
HeaderEnd: CRLF
I expected to see either Content-Length or Transfer-Encoding, but none of them exist.
I read the HTTP-RFC but am still unsure.
@CodeCaster, I did read RFC section 4.4, but am still not clear, as you can see, the response header is used to return a json stream, so:
- section 4.4, rule 1 defines MUST NOT include a message-body, does not seem to apply to my case.
- section 4.4, rule 4, not sure about this, but since I do not see "multipart/byteranges" in the response header - does it mean this rule is not applicable for me?
- section 4.4 rule 5, this is mostly unclear to me since the header actual contain "Connection : close", is it related?
So, any further comments?
Yes, it is valid. There are five ways to determine the message length: