18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: http.c,v 1.282 2006-05-05 22:14:40 bagder Exp $
21
* $Id: http.c,v 1.287 2006-08-02 18:18:49 bagder Exp $
22
22
***************************************************************************/
1128
1128
if(CURLE_OK == result) {
1129
1129
char *host=(char *)"";
1130
1130
const char *proxyconn="";
1133
ptr = checkheaders(data, "Host:");
1132
if(!checkheaders(data, "Host:")) {
1135
1133
host = aprintf("Host: %s\r\n", host_port);
1137
1135
result = CURLE_OUT_OF_MEMORY;
1139
ptr = checkheaders(data, "Proxy-Connection:");
1137
if(!checkheaders(data, "Proxy-Connection:")) {
1141
1138
proxyconn = "Proxy-Connection: Keep-Alive\r\n";
1143
1141
if(CURLE_OK == result) {
1144
1142
/* Send the connect request to the proxy */
1556
1554
header as that will produce *two* in the same request! */
1557
1555
curl_strnequal("Host:", headers->data, 5))
1557
else if(conn->data->set.httpreq == HTTPREQ_POST_FORM &&
1558
/* this header (extended by formdata.c) is sent later */
1559
curl_strnequal("Content-Type:", headers->data,
1560
strlen("Content-Type:")))
1561
1563
result = add_bufferf(req_buffer, "%s\r\n", headers->data);
1682
1684
return CURLE_OUT_OF_MEMORY;
1685
if(!conn->bits.upload_chunky && (httpreq != HTTPREQ_GET)) {
1686
/* not a chunky transfer yet, but data is to be sent */
1687
ptr = checkheaders(data, "Transfer-Encoding:");
1689
/* Some kind of TE is requested, check if 'chunked' is chosen */
1690
conn->bits.upload_chunky =
1691
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
1687
ptr = checkheaders(data, "Transfer-Encoding:");
1689
/* Some kind of TE is requested, check if 'chunked' is chosen */
1690
conn->bits.upload_chunky =
1691
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
1695
else if(conn->bits.upload_chunky) {
1696
/* RFC2616 section 4.4:
1697
Messages MUST NOT include both a Content-Length header field and a
1698
non-identity transfer-coding. If the message does include a non-
1699
identity transfer-coding, the Content-Length MUST be ignored. */
1701
if(!checkheaders(data, "Transfer-Encoding:")) {
1694
if (httpreq == HTTPREQ_GET)
1695
conn->bits.upload_chunky = FALSE;
1696
if(conn->bits.upload_chunky)
1702
1697
te = "Transfer-Encoding: chunked\r\n";
1706
conn->bits.upload_chunky = FALSE; /* transfer-encoding was disabled,
1707
so don't chunkify this! */
1711
1700
Curl_safefree(conn->allocptr.host);
1773
1762
uses the encoded host name! */
1774
1763
if(conn->host.dispname != conn->host.name) {
1775
1764
char *url = data->change.url;
1776
char *ptr = strstr(url, conn->host.dispname);
1765
ptr = strstr(url, conn->host.dispname);
1778
1767
/* This is where the display name starts in the URL, now replace this
1779
1768
part with the encoded name. TODO: This method of replacing the host
1811
1800
/* we must build the whole darned post sequence first, so that we have
1812
1801
a size of the whole shebang before we start to send it */
1813
1802
result = Curl_getFormData(&http->sendit, data->set.httppost,
1803
checkheaders(data, "Content-Type:"),
1814
1804
&http->postsize);
1815
1805
if(CURLE_OK != result) {
1816
1806
/* Curl_getFormData() doesn't use failf() */
1970
1960
(data->set.encoding && *data->set.encoding && conn->allocptr.accept_encoding)?
1971
1961
conn->allocptr.accept_encoding:"",
1972
1962
(data->change.referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: <data> */,
1973
(conn->bits.httpproxy && !conn->bits.tunnel_proxy)?
1963
(conn->bits.httpproxy &&
1964
!conn->bits.tunnel_proxy &&
1965
!checkheaders(data, "Proxy-Connection:"))?
1974
1966
"Proxy-Connection: Keep-Alive\r\n":"",
2137
if(!checkheaders(data, "Content-Type:")) {
2138
2131
/* Get Content-Type: line from Curl_formpostheader.
2140
The Content-Type header line also contains the MIME boundary
2141
string etc why disabling this header is likely to not make things
2142
work, but we support disabling it anyway.
2144
2133
char *contentType;
2145
2134
size_t linelength=0;
2149
2138
failf(data, "Could not get Content-Type header line!");
2150
2139
return CURLE_HTTP_POST_ERROR;
2152
2142
result = add_buffer(req_buffer, contentType, linelength);