views:

47

answers:

3

In http transaction for request and response which scenario is occurred ?

  1. client (web browser) open connection and send it's request and connection open (keep alive) until server accept and answer then close connection ?
  2. client (web browser) open connection and send it's request then connection is closed and server accept and answer and reconnect and send response ?

in http1.0 and http1.1 this scenario is different ?

+1  A: 

A server can't directly reconnect to a client. Hence, your scenario #2 is unlikely.

In other words, in the WEB world, "transactions" between a Client Browser and a WEB Server is always "Client Browser Initiated".


Of course, if we are talking about server-to-server communication over HTTP, it is a different story: you can make up your own rules here, provided you control at least one server ;-)


As for the difference between HTTP 1.0 and HTTTP 1.1, I don't know enough.

jldupont
+1  A: 

The scenario is:

  1. The client (browser) opens a connection to the web server and sends HTTP request
  2. The server receives the request and sends back the response to the client (browser)

If keep alive is enabled, the connection will not be closed until the keep alive timeout expires. The idea of keep alive is to use the same TCP connect to send/receive multiple requests/responses.

Persistent connection / Keep alive was officially introduced in the HTTP 1.1 specification. keep-alive was not officially documented in the specification of HTTP 1.0, however, some implementation of HTTP 1.0 supported keep alive connections.

regarding scenario 2: The server never initiate connections with browsers, the browser initiate connections with the server and the server uses the same connection to send back responses.

+1  A: 

In both 1.0 and 1,1 connection is kept open until response is sent. Keep alive refers to what happens afterwards.

In HTTP 1.0 server closes the connection after sending the response. Unless client sends and server understands keep-alive header (which was not a part of HTTP 1.0 standard)

In HTTP 1.1 connection is kept open after the response unless client sends Connection: close header.

Details

yu_sha