~ubuntu-branches/ubuntu/intrepid/curl/intrepid

« back to all changes in this revision

Viewing changes to lib/http.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:56:48 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030105648-uo8q8w9xklb40b4k
Tags: 7.15.5-1ubuntu1
* Merge from debian unstable. Remaining Ubuntu changes:
  - debian/control: Drop libdb4.2 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
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
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
1128
1128
    if(CURLE_OK == result) {
1129
1129
      char *host=(char *)"";
1130
1130
      const char *proxyconn="";
1131
 
      char *ptr;
1132
1131
 
1133
 
      ptr = checkheaders(data, "Host:");
1134
 
      if(!ptr) {
 
1132
      if(!checkheaders(data, "Host:")) {
1135
1133
        host = aprintf("Host: %s\r\n", host_port);
1136
1134
        if(!host)
1137
1135
          result = CURLE_OUT_OF_MEMORY;
1138
1136
      }
1139
 
      ptr = checkheaders(data, "Proxy-Connection:");
1140
 
      if(!ptr)
 
1137
      if(!checkheaders(data, "Proxy-Connection:")) {
1141
1138
        proxyconn = "Proxy-Connection: Keep-Alive\r\n";
 
1139
      }
1142
1140
 
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))
1558
1556
          ;
 
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
          ;
1559
1562
        else {
1560
 
 
1561
1563
          result = add_bufferf(req_buffer, "%s\r\n", headers->data);
1562
1564
          if(result)
1563
1565
            return result;
1682
1684
      return CURLE_OUT_OF_MEMORY;
1683
1685
  }
1684
1686
 
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:");
1688
 
    if(ptr) {
1689
 
      /* Some kind of TE is requested, check if 'chunked' is chosen */
1690
 
      conn->bits.upload_chunky =
1691
 
        Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
1692
 
      te = "";
1693
 
    }
 
1687
  ptr = checkheaders(data, "Transfer-Encoding:");
 
1688
  if(ptr) {
 
1689
    /* Some kind of TE is requested, check if 'chunked' is chosen */
 
1690
    conn->bits.upload_chunky =
 
1691
      Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
1694
1692
  }
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. */
1700
 
 
1701
 
    if(!checkheaders(data, "Transfer-Encoding:")) {
 
1693
  else {
 
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";
1703
 
    }
1704
 
    else {
1705
 
      te = "";
1706
 
      conn->bits.upload_chunky = FALSE; /* transfer-encoding was disabled,
1707
 
                                           so don't chunkify this! */
1708
 
    }
1709
1698
  }
1710
1699
 
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);
1777
1766
      if(ptr) {
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":"",
1975
1967
                te
1976
1968
                );
2134
2126
      if(result)
2135
2127
        return result;
2136
2128
 
2137
 
      if(!checkheaders(data, "Content-Type:")) {
 
2129
      {
 
2130
 
2138
2131
        /* Get Content-Type: line from Curl_formpostheader.
2139
 
 
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.
2143
2132
        */
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;
2151
2140
        }
 
2141
 
2152
2142
        result = add_buffer(req_buffer, contentType, linelength);
2153
2143
        if(result)
2154
2144
          return result;