Commit 94ec5ff4 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

correct the POST workings. Tim Tassonis reported.

parent e54f09a2
Loading
Loading
Loading
Loading
+34 −36
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ CURLcode http(struct connectdata *conn)
{
  struct UrlData *data=conn->data;
  char *buf = data->buffer; /* this is a short cut to the buffer */
  CURLcode result;
  CURLcode result=CURLE_OK;
  struct HTTP *http;
  struct Cookie *co=NULL; /* no cookies from start */
  char *ppath = conn->ppath; /* three previous function arguments */
@@ -370,18 +370,7 @@ CURLcode http(struct connectdata *conn)
      headers = headers->next;
    }

    if(data->bits.http_post || data->bits.http_formpost) {
      if(data->bits.http_post) {
        /* this is the simple x-www-form-urlencoded style */
        sendf(data->firstsocket, data,
              "Content-Length: %d\015\012"
              "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
              "%s\015\012",
              strlen(data->postfields),
              data->postfields );
      }
      else {

    if(data->bits.http_formpost) {
      if(FormInit(&http->form, http->sendit)) {
        failf(data, "Internal HTTP POST error!\n");
        return CURLE_HTTP_POST_ERROR;
@@ -411,7 +400,6 @@ CURLcode http(struct connectdata *conn)
        return result;
      }
    }
    }
    else if(data->bits.http_put) {
      /* Let's PUT the data to the server! */

@@ -435,6 +423,16 @@ CURLcode http(struct connectdata *conn)
      
    }
    else {
      if(data->bits.http_post) {
        /* this is the simple x-www-form-urlencoded style */
        sendf(data->firstsocket, data,
              "Content-Length: %d\015\012"
              "Content-Type: application/x-www-form-urlencoded\r\n\r\n"
              "%s\r\n",
              strlen(data->postfields),
              data->postfields );
      }
      else
        sendf(data->firstsocket, data, "\r\n");

      /* HTTP GET/HEAD download: */