Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How browser maps the web response back to request?

Tags:

browser

http

tcp

Say i make the web request(www.amazon.com) to amazon web server through browser. Browser makes the connection with Internet through Internet service providers. Request reaches to amazon server which process it and send back the response. Two questions here :-

  1. Does Amazon server makes new connection with internet to send the response back or incoming request(initiated by me) waits on socket till amazon process the response ?
  2. Once my browser receives the response how does it map the response(sent from amazon) back to particular request . I believe there must be some unique identifier like requestId must be present in response through which browser must be mapping to request. Is that correct ?
like image 932
user3198603 Avatar asked Feb 06 '23 04:02

user3198603


1 Answers

  1. Does Amazon server makes new connection with internet to send the response back or incoming request(initiated by me) waits on socket till amazon process the response ?

It uses the same connection. Most of the time it's not even possible to connect back to a web browser due to firewall restrictions or Network Address Translation (NAT).

  1. Once my browser receives the request how does it map the response(sent from amazon) back to particular request . I believe there must be some unique identifier like requestId must be present in response through which browser must be mapping to request. Is that correct ?

It receives the response on the same socket. So the socket is the identifier. If HTTP2 multiplexing is used, then each multiplexed stream has a stream identifier, which is used to map the response back to the request.

like image 107
Erwin Bolwidt Avatar answered Feb 27 '23 14:02

Erwin Bolwidt