]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: httpclient: don't add body when istlen is empty
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 13:49:43 +0000 (14:49 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 13:49:43 +0000 (14:49 +0100)
Don't try to create a request with a body in httpclient_req_gen() if the
payload ist has a ptr but no len.

Sometimes people have their httpclient stuck because they use an ist
with a data ptr but no len. Check the len so this mistake doesn't block
the client.

src/http_client.c

index b3366406472b954e430a8eba671c724e2e9e8130..bd398237e8e0e0226ab23f9d1b697db1ad1cb4ae 100644 (file)
@@ -343,7 +343,7 @@ int httpclient_req_gen(struct httpclient *hc, const struct ist url, enum http_me
        if (!htx_add_endof(htx, HTX_BLK_EOH))
                goto error;
 
-       if (isttest(payload)) {
+       if (isttest(payload) && istlen(payload)) {
                /* add the payload if it can feat in the buffer, no need to set
                 * the Content-Length, the data will be sent chunked */
                if (!htx_add_data_atonce(htx, payload))