mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
HTTP POST: omit Content-Length if data size is unknown
This prevents sending a `Content-Length: -1` header, e.g this ocurred with the following combination: * standard HTTP POST (no chunked encoding), * user-defined read function set, * `CURLOPT_POSTFIELDSIZE(_LARGE)` NOT set. With this fix it now behaves like HTTP PUT.
This commit is contained in:
parent
39f7e80a52
commit
afd288b28f
@ -2408,12 +2408,12 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
data->set.postfieldsize:
|
data->set.postfieldsize:
|
||||||
(data->set.postfields? (curl_off_t)strlen(data->set.postfields):-1);
|
(data->set.postfields? (curl_off_t)strlen(data->set.postfields):-1);
|
||||||
}
|
}
|
||||||
if(!data->req.upload_chunky) {
|
|
||||||
/* We only set Content-Length and allow a custom Content-Length if
|
/* We only set Content-Length and allow a custom Content-Length if
|
||||||
we don't upload data chunked, as RFC2616 forbids us to set both
|
we don't upload data chunked, as RFC2616 forbids us to set both
|
||||||
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
||||||
|
if((postsize != -1) && !data->req.upload_chunky &&
|
||||||
if(conn->bits.authneg || !Curl_checkheaders(data, "Content-Length:")) {
|
!Curl_checkheaders(data, "Content-Length:")) {
|
||||||
/* we allow replacing this header if not during auth negotiation,
|
/* we allow replacing this header if not during auth negotiation,
|
||||||
although it isn't very wise to actually set your own */
|
although it isn't very wise to actually set your own */
|
||||||
result = Curl_add_bufferf(req_buffer,
|
result = Curl_add_bufferf(req_buffer,
|
||||||
@ -2422,7 +2422,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(!Curl_checkheaders(data, "Content-Type:")) {
|
if(!Curl_checkheaders(data, "Content-Type:")) {
|
||||||
result = Curl_add_bufferf(req_buffer,
|
result = Curl_add_bufferf(req_buffer,
|
||||||
|
Loading…
Reference in New Issue
Block a user