Skip to content

Fix pipelined requests handling

When sending concatenated requests, due to the behavior of async_read_until, a part of the second request can be lost.

Solution: initialize the new session with the remainder of the request buffer

while adding a streambuf dedicated to the content only.

Test: while running the http_examples program

$ echo -en "GET /match/4444 HTTP/1.1\r\n\r\nGET /match/1234 HTTP/1.1\r\n\r\n" | nc localhost 8080
HTTP/1.1 200 OK
Content-Length: 4

4444HTTP/1.1 200 OK
Content-Length: 4

1234

$ echo -en "POST /string HTTP/1.1\r\nContent-Length: 8\r\n\r\nA stringGET /match/1234 HTTP/1.1\r\n\r\n" | nc localhost 8080
HTTP/1.1 200 OK
Content-Length: 8

A stringHTTP/1.1 200 OK
Content-Length: 4

1234

$ echo -en "POST /string HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n6\r\nHello \r\n5\r\nWorld\r\n0\r\n\r\nGET /match/1234 HTTP/1.1\r\n\r\n" | nc localhost 8080
HTTP/1.1 200 OK
Content-Length: 11

Hello WorldHTTP/1.1 200 OK
Content-Length: 4

1234
Edited by michirod

Merge request reports