http header: allow Content-Length to be replaced

In some cases Content-Length: couldn't be replaced by an application

Also, indented some code properly
This commit is contained in:
Daniel Stenberg 2011-09-24 00:05:58 +02:00
parent 87a45c7998
commit 5f0764870f
1 changed files with 67 additions and 63 deletions

View File

@ -2116,7 +2116,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(result)
return result;
result = Curl_add_bufferf(req_buffer,
result =
Curl_add_bufferf(req_buffer,
"%s" /* ftp typecode (;type=x) */
" HTTP/%s\r\n" /* HTTP version */
"%s" /* proxyuserpwd */
@ -2139,9 +2140,10 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
(data->state.use_range && conn->allocptr.rangeline)?
conn->allocptr.rangeline:"",
(data->set.str[STRING_USERAGENT] &&
*data->set.str[STRING_USERAGENT] && conn->allocptr.uagent)?
*data->set.str[STRING_USERAGENT] &&
conn->allocptr.uagent)?
conn->allocptr.uagent:"",
(conn->allocptr.host?conn->allocptr.host:""), /* Host: host */
(conn->allocptr.host?conn->allocptr.host:""),
http->p_accept?http->p_accept:"",
conn->allocptr.te?conn->allocptr.te:"",
(data->set.str[STRING_ENCODING] &&
@ -2277,7 +2279,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
http->sending = HTTPSEND_BODY;
if(!data->req.upload_chunky) {
if(!data->req.upload_chunky &&
!Curl_checkheaders(data, "Content-Length:")) {
/* only add Content-Length if not uploading chunked */
result = Curl_add_bufferf(req_buffer,
"Content-Length: %" FORMAT_OFF_T "\r\n",
@ -2348,7 +2351,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else
postsize = data->set.infilesize;
if((postsize != -1) && !data->req.upload_chunky) {
if((postsize != -1) && !data->req.upload_chunky &&
!Curl_checkheaders(data, "Content-Length:")) {
/* only add Content-Length if not uploading chunked */
result = Curl_add_bufferf(req_buffer,
"Content-Length: %" FORMAT_OFF_T "\r\n",