'How http ensure the response data belong to which request when keep-alive is on
http header connection:keep-alive allow multi requests share the same socket to reduce the tcp cost on creation and destroy, so the same socket will receive the response data that belong to each individual request. my question is how http protocol define this part, how response data find its related request, or it something outside http
Solution 1:[1]
HTTP/1 (where keep-alive is relevant) has a clearly defined message format which makes it possible to determine when a request and respond end and a new one starts - see RFC 7230 Message Format for the details. An application needs to understand this message format when handling HTTP.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steffen Ullrich |
