1
votes

I was studying http protocol in detail and come across this tutorial. I think when http request is made, a TCP connection is established b/w client(browser) and server. On that TCP connection http request data is sent, on server side http request is parsed and on the same TCP connection http response is sent. After response is sent, TCP connection is terminated. For next http request a new TCP connection will be established. But below tutorial saying something else. Am I right or wrong?

enter image description here

1
Yeah that paragraph makes no sense whatsoever. The server does not "re-establish" the connection in any way, it connection is kept alive for at least one request-response pair. - CodeCaster

1 Answers

7
votes

HTTP is stateless, not connection-less. That paragraph is wrong, the connection is connected until, at least, the response is sent back to the caller. In practice, the same connection is reused if several requests to the same endpoint needs to be done, and since HTTP/1.1 is it possible to send many requests at once and wait for responses in the same order.