Skip to content

Commit

Permalink
Merge pull request #3567 from MartinNowak/fix14760
Browse files Browse the repository at this point in the history
fix Issue 14760 - Clear content-length for libcurl
  • Loading branch information
DmitryOlshansky committed Aug 21, 2015
2 parents fe6122c + 404c3cd commit fadfe88
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions std/net/curl.d
Expand Up @@ -768,7 +768,7 @@ private auto _basicHTTP(T)(const(char)[] url, const(void)[] sendData, HTTP clien
{
client.onSend = null;
client.handle.onSeek = null;
client.clearContentLength();
client.contentLength = 0;
}
}
client.url = url;
Expand Down Expand Up @@ -847,6 +847,24 @@ unittest
assert(e.msg == "HTTP request returned status code 404 (Not Found)");
}

// Bugzilla 14760 - content length must be reset after post
unittest
{
//if (!netAllowed()) return;
auto http = HTTP();
{
string data = "Hello world";
auto res = post(testUrl2, data, http);
assert(res == data,
"post!HTTP() returns unexpected content " ~ res);
}
{
auto res = trace(testUrl1, http);
assert(res == "Hello world\n",
"trace!HTTP() returns unexpected content " ~ res);
}
}

/*
* Helper function for the high level interface.
*
Expand Down Expand Up @@ -2818,35 +2836,6 @@ struct HTTP
}
}

// Clear ContentLength depending on method.
void clearContentLength()
{
CurlOption lenOpt;
if (p.method == Method.put)
lenOpt = CurlOption.infilesize_large;
else
lenOpt = CurlOption.postfieldsize_large;
p.curl.clear(lenOpt);
}

// segmentation fault test
unittest
{
if (!netAllowed()) return;
auto http = HTTP();
{
string data = "Hello world";
auto res = post(testUrl2, data, http);
assert(res == data,
"post!HTTP() returns unexpected content " ~ res);
}
{
auto res = trace(testUrl1, http);
assert(res == "Hello world\n",
"trace!HTTP() returns unexpected content " ~ res);
}
}

/**
Authentication method as specified in $(LREF AuthMethod).
*/
Expand Down

0 comments on commit fadfe88

Please sign in to comment.