From: Daniel Stenberg Date: Fri, 9 Sep 2016 13:57:44 +0000 (+0200) Subject: http: refuse to pass on response body with NO_NODY was set X-Git-Tag: curl-7_50_3~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8e751a51a53c59e832c8351a1356763fa5766c4;p=curl http: refuse to pass on response body with NO_NODY was set ... like when a HTTP/0.9 response comes back without any headers at all and just a body this now prevents that body from being sent to the callback etc. Adapted test 1144 to verify. Fixes #973 Assisted-by: Ray Satiro --- diff --git a/lib/transfer.c b/lib/transfer.c index 2fad6f32f..24bdf2155 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -535,6 +535,13 @@ static CURLcode readwrite_data(struct Curl_easy *data, is non-headers. */ if(k->str && !k->header && (nread > 0 || is_empty_data)) { + if(data->set.opt_no_body) { + /* data arrives although we want none, bail out */ + streamclose(conn, "ignoring body"); + *done = TRUE; + return CURLE_WEIRD_SERVER_REPLY; + } + #ifndef CURL_DISABLE_HTTP if(0 == k->bodywrites && !is_empty_data) { /* These checks are only made the first time we are about to diff --git a/tests/data/test1144 b/tests/data/test1144 index 3b4a1b479..3fb90936a 100644 --- a/tests/data/test1144 +++ b/tests/data/test1144 @@ -30,6 +30,10 @@ data to verify +# make sure no data is written + + + # @@ -58,5 +62,8 @@ Host: %HOSTIP:%HTTPPORT Accept: */* + +8 +