mirror of
https://github.com/curl/curl.git
synced 2025-09-14 08:02:44 +03:00
only use Content-Length: header if not transfering data chunked
This commit is contained in:
parent
13a903de28
commit
bf678a1ca9
43
lib/http.c
43
lib/http.c
|
@ -617,6 +617,11 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conn->bits.upload_chunky) {
|
if(conn->bits.upload_chunky) {
|
||||||
|
/* RFC2616 section 4.4:
|
||||||
|
Messages MUST NOT include both a Content-Length header field and a
|
||||||
|
non-identity transfer-coding. If the message does include a non-
|
||||||
|
identity transfer-coding, the Content-Length MUST be ignored. */
|
||||||
|
|
||||||
if(!checkheaders(data, "Transfer-Encoding:")) {
|
if(!checkheaders(data, "Transfer-Encoding:")) {
|
||||||
te = "Transfer-Encoding: chunked\r\n";
|
te = "Transfer-Encoding: chunked\r\n";
|
||||||
}
|
}
|
||||||
|
@ -926,8 +931,10 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||||
generated form data */
|
generated form data */
|
||||||
data->set.in = (FILE *)&http->form;
|
data->set.in = (FILE *)&http->form;
|
||||||
|
|
||||||
add_bufferf(req_buffer,
|
if(!conn->bits.upload_chunky)
|
||||||
"Content-Length: %d\r\n", http->postsize);
|
/* only add Content-Length if not uploading chunked */
|
||||||
|
add_bufferf(req_buffer,
|
||||||
|
"Content-Length: %d\r\n", http->postsize);
|
||||||
|
|
||||||
if(!checkheaders(data, "Expect:")) {
|
if(!checkheaders(data, "Expect:")) {
|
||||||
/* if not disabled explicitly we add a Expect: 100-continue
|
/* if not disabled explicitly we add a Expect: 100-continue
|
||||||
|
@ -985,13 +992,13 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||||
|
|
||||||
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
|
case HTTPREQ_PUT: /* Let's PUT the data to the server! */
|
||||||
|
|
||||||
if(data->set.infilesize>0) {
|
if((data->set.infilesize>0) && !conn->bits.upload_chunky)
|
||||||
|
/* only add Content-Length if not uploading chunked */
|
||||||
add_bufferf(req_buffer,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: %d\r\n\r\n", /* file size */
|
"Content-Length: %d\r\n", /* file size */
|
||||||
data->set.infilesize );
|
data->set.infilesize );
|
||||||
}
|
|
||||||
else
|
add_bufferf(req_buffer, "\r\n");
|
||||||
add_bufferf(req_buffer, "\015\012");
|
|
||||||
|
|
||||||
/* set the upload size to the progress meter */
|
/* set the upload size to the progress meter */
|
||||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||||
|
@ -1014,14 +1021,20 @@ CURLcode Curl_http(struct connectdata *conn)
|
||||||
case HTTPREQ_POST:
|
case HTTPREQ_POST:
|
||||||
/* this is the simple POST, using x-www-form-urlencoded style */
|
/* this is the simple POST, using x-www-form-urlencoded style */
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Length:"))
|
if(!conn->bits.upload_chunky) {
|
||||||
/* we allow replacing this header, although it isn't very wise to
|
/* We only set Content-Length and allow a custom Content-Length if
|
||||||
actually set your own */
|
we don't upload data chunked, as RFC2616 forbids us to set both
|
||||||
add_bufferf(req_buffer,
|
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
|
||||||
"Content-Length: %d\r\n",
|
|
||||||
data->set.postfieldsize?
|
if(!checkheaders(data, "Content-Length:"))
|
||||||
data->set.postfieldsize:
|
/* we allow replacing this header, although it isn't very wise to
|
||||||
(data->set.postfields?strlen(data->set.postfields):0) );
|
actually set your own */
|
||||||
|
add_bufferf(req_buffer,
|
||||||
|
"Content-Length: %d\r\n",
|
||||||
|
data->set.postfieldsize?
|
||||||
|
data->set.postfieldsize:
|
||||||
|
(data->set.postfields?strlen(data->set.postfields):0) );
|
||||||
|
}
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Type:"))
|
if(!checkheaders(data, "Content-Type:"))
|
||||||
add_bufferf(req_buffer,
|
add_bufferf(req_buffer,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user