Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an persistent HTTP client send more than one request at a time?

I am writing a HTTP proxy server and I noticed that many clients use the "Connection: Keep-Alive" header to keep a persistent connection. Is it possible that the client sends another HTTP request before the server processes the first?

For example, the client sends "GET / HTTP/1.1" but before the server has a chance to respond, the client sends "GET /favicon.ico HTTP/1.1". Is that possible? Or will the client pause for the response before sending the second request?

Also, when using a persistent connection, is it safe to assume all requests through that connection will have the same "Host: " header?

like image 263
Yifan Avatar asked Nov 06 '11 16:11

Yifan


People also ask

What does a persistent connection allow an HTTP client?

HTTP has a persistent connection function that allows the channel to remain open rather than be closed after a requested exchange of data. TCP is a connection-oriented protocol: It starts a connection after confirmation from both ends that they are available and open to a data exchange.

What is the performance advantage of persistent HTTP over non-persistent HTTP?

With persistent connections, the performance is improved by 20%. Nonpersistent connections are the default mode for HTTP/1.0 and persistent connections are the default mode for HTTP/1.1.

Can a client open three or more simultaneous connections with a given server?

Yes, a client can open three or more simultaneous connections with a given server, although the suggested number of concurrent persistent connections is two. d. Closing the connection by one side is possible while the other side is transmitting.

Is HTTP 2 persistent connection?

As a result, all HTTP/2 connections are persistent, and only one connection per origin is required, which offers numerous performance benefits. For both SPDY and HTTP/2 the killer feature is arbitrary multiplexing on a single well congestion controlled channel.


1 Answers

"Also, when using a persistent connection, is it safe to assume all requests through that connection will have the same "Host: " header?"

I don't think so, see HTTPbis P1, Section 2.2:

Recipients MUST consider every message in a connection in isolation; because HTTP is a stateless protocol, it cannot be assumed that two requests on the same connection are from the same client or share any other common attributes. In particular, intermediaries might mix requests from different clients into a single server connection. Note that some existing HTTP extensions (e.g., [RFC4559]) violate this requirement, thereby potentially causing interoperability and security problems.

like image 178
Julian Reschke Avatar answered Oct 12 '22 11:10

Julian Reschke