1

I'm trying to understand why a single HTTP response is split in 2 parts in the following setup:

  • Requested resource is protected by HTTP Digest Authentication on server side.
  • Communication is performed using TLS 1.0.

When client requests a resource then server response is split in 2 parts: first part (after decryption) contains only HTTP headers (besides other):

Content-Length: 1297
and
WWW-Authenticate: ...
Second part contains the body message.

The most important thing: this first part containing only headers is sent with PSH flag which causes that my application throws an exception because Content-Length is > 0 but there is no body message. The last packet of the second part does not have PSH flag.

Is this behaviour of server correct?

1 Answer 1

2

Your application is probably not aware that TCP is a stream- and not packet-based protocol. There is no guarantee, that you get header and body together in a single packet, there is even no guarantee that you get the whole header inside a single packet.

Apart from that, the response contains to major parts: the content and information about the content (type, length, last changed...). There are several ways to distinguish between these parts and of is to split it into a header containing the meta information and the body containing the content.

2
  • I understand everything you said but why PSH flag is set in the first part of response containing only headers rather than in the last packet of the second part? I thought that PSH flag is used to inform the receiver that the sender has no further data to transmit (for now).
    – Paul
    Apr 13, 2014 at 19:10
  • Not necessary finished sending data, but having the current data delivered without buffering. It makes sense to get the header immediately, because from the header you know how much body data you'll need to read. So it can make sense for an application to send the header immediately. On the other side it would be a waste of bandwidth if header and body are small and would together fit into a single packet. Sou you cannot count on getting the header inside a single packet. Apr 14, 2014 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .