views:

274

answers:

4

what byte/bytes do you send to conclude a HTTP server response?

+3  A: 

There is no marker -- rather, in the HTTP response header there is a Content-Length field describing the length of the response body

If you're interested in examining and learning about the HTTP protocol, I would download the tool Fiddler at http://www.fiddler2.com/fiddler2/

You can then look "behind the scenes" at what happens when you visit a web page and see the request and response text.

Clyde
So say the optional Content-Length header is left out. How does the client know that the full response body has been recieved if the server connection is closed?
divinci
That's up for the client to decide. Presumably if the server closed the connection it was finished, but of course there's always the possibility of a network error artificially closing the connection. If they sent the content-length header, you'll be able to tell the difference. If they didn't, you have no way of knowing, and just have to do the best you can with what they sent you
Clyde
+2  A: 

From RFC 2616(HTTP 1.1)

HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body (see appendix 19.3 for tolerant applications). The end-of-line marker within an entity-body is defined by its associated media type, as described in section 3.7.

CookieOfFortune
He asked for the end-of-response, not end-of-line
Clyde
+3  A: 

There is no such byte. The connection may be terminated by either side.

There is the optional Content-Length header, but it's a kind of hint for the client to know the size of the response.

tuler
So say the optional Content-Length header is left out.How does the client know that the full response body has been recieved if the server connection is closed?
divinci
The client doesn't know. If the connection is dropped by the server, it finished the response, or an error ocurred. Depending on the content-type of the response the client may analyze it.
tuler
+1  A: 

The response length is determined by closing the connection (HTTP/1.0), the Content-Length response header, or the use of Chunked Encoding.

See HTTPbis, Part 1, Section 4.4.

Julian Reschke