How does a http client associate an http response with a request (with Netty) or in general?

I won't re-write CodeCaster's answer because it is very well worded.

I won't re-write CodeCaster's answer because it is very well worded. In response to your edit - no. It is not.

A single persistent HTTP connection can only be used for one request at once, or it would get very confusing. Because HTTP does not define any form of request/response tracking mechanism, it simply would not be possible. It should be noted that there are other protocols which use a similar message format (conforming to RFC822), which do allow for this (using mechanisms such as SIP's cSeq header), and it would be possible to implement this in a custom HTTP app, but HTTP does not define any standard mechanism for doing this, and therefore nothing can be done that could be assumed to work everywhere.It would also present a problem with the response for the second message - do you wait for the first response to finish before sending the second response, or try and pause the first response while you send the second response?

How will you communicate this in a way that guarantees messages won't become corrupted? Note also that SIP (usually) operates over UDP, which does not guarantee packet ordering, making the cSeq system more of a necessity. If you want to send a request to a server while another transaction is still in progress, you will need to create a new connection to the server, and hence a new TCP stream.

Facebook did some research into this while they were building their CDN, and they concluded that you can efficiently have 2 or 3 open HTTP streams at any one time, but any more than that reduces overall transfer time because of the extra packet overhead cost. I would link to the blog entry if I could find the link...

Whenever a TCP connection is opened, the connection is recognized by the source and destination ports and IP addresses. So if I connect to google.com on destination port 80 (default for HTTP), I need a free source port which the OS will generate. The reply of the web server is then sent to the source port (and IP).

This is also how NAT works, remembering which source port belongs to which internal IP address (and vice versa for incoming connections). As for your edit: no, a single http connection can execute one command (GET/POST/etc) at the same time. If you send another command while you are retreiving data from a previously issued command, the results may vary per client and server implementation.

I guess that Apache, for example, will transmit the result of the second request after the data of the first request is sent.

1 +1 - Nice succinct explaination. Altoid Muncher, I think you might do well to read up on some of the basics of TCP, the transport layer protocol that HTTP (usually) operates on. Relatively high-level software such as a web browser or cURL does not have to worry about this, it is handled by the underlying TCP/IP stack of the operating system.

For further reading that is closely related to this, as @CodeCaster mentioned, read up on NAT (Network Address Translation) – DaveRandom Sep 5 at 10:17.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions