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
This commit is contained in:
Daniel Stenberg 2016-09-09 15:57:44 +02:00
parent d58682f28b
commit a8e751a51a
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -30,6 +30,10 @@ data to
verify
</data>
# make sure no data is written
<datacheck nonewline="yes">
</datacheck>
</reply>
#
@ -58,5 +62,8 @@ Host: %HOSTIP:%HTTPPORT
Accept: */*
</protocol>
<errorcode>
8
</errorcode>
</verify>
</testcase>