Skip to content

Commit

Permalink
http_client: mark connection as non-reuseable on failure
Browse files Browse the repository at this point in the history
flb_http_client supports internal buffer size limit. If server
tries to send more data than the maximum size limit, the client
will refuse to receive it.

This behaviour is problematic when combined with keep-alive mode;
Since flb_http_do() can leave some data in the socket, the next
HTTP request can be confused by the leftover.

For example, if the socket has the following data (unread):

    "data":["from", "previous", "conn"]}

The next HTTP request will see the following response:

    "data":["from", "previous", "conn"]}HTTP/1.1 200 OK
    Content-Type: text/html
    Accept-Ranges: bytes
    Last-Modified: Sat, 30 May 2020 23:47:16 GMT
    ...

Signed-off-by: Fujimoto Seiji <fujimoto@ceptord.net>
  • Loading branch information
fujimotos authored and edsiper committed Jul 3, 2020
1 parent 1c4c200 commit 7533d1f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/flb_http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ int flb_http_do(struct flb_http_client *c, size_t *bytes)
* We could not allocate more space, let the caller handle
* this.
*/
flb_upstream_conn_recycle(c->u_conn, FLB_FALSE);
return 0;
}
available = flb_http_buffer_available(c) - 1;
Expand Down

0 comments on commit 7533d1f

Please sign in to comment.