cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Re: Re: Re: Re: [PATCH] allows curl to be able to send the custom headers with empty value.

From: warp kawada <warp.kawada_at_gmail.com>
Date: Mon, 29 Aug 2011 17:20:45 +0900

here you are.

CURLcode Curl_add_custom_headers(struct connectdata *conn,
                                   Curl_send_buffer *req_buffer)
{
  char *ptr;
  struct curl_slist *headers=conn->data->set.headers;
  CURLcode result;

  while(headers) {
    ptr = strchr(headers->data, ':');
    if(ptr) {
      /* we require a colon for this to be a true header */

      ptr++; /* pass the colon */
      while(*ptr && ISSPACE(*ptr))
        ptr++;

      if(*ptr) {
        /* only send this if the contents was non-blank */

        if(conn->allocptr.host &&
           /* a Host: header was sent already, don't pass on any custom Host:
              header as that will produce *two* in the same request! */
           checkprefix("Host:", headers->data))
          ;
        else if(conn->data->set.httpreq == HTTPREQ_POST_FORM &&
                /* this header (extended by formdata.c) is sent later */
                checkprefix("Content-Type:", headers->data))
          ;
        else if(conn->bits.authneg &&
                /* while doing auth neg, don't allow the custom length since
                   we will force length zero then */
                checkprefix("Content-Length", headers->data))
          ;
        else if(conn->allocptr.te &&
                /* when asking for Transfer-Encoding, don't pass on a custom
                   Connection: */
                checkprefix("Connection", headers->data))
          ;
        else {
          result = Curl_add_bufferf(req_buffer, "%s\r\n",
                                             headers->data);
          if(result)
            return result;
        }
      }
    }
    else {
      ptr = strchr(headers->data, ';');
      /* send non-value custom header if terminated by semicolon */
      if (ptr) {
        if(*(ptr + 1) == '\0') {
          *ptr = ':';
          result = Curl_add_bufferf(req_buffer, "%s\r\n",
                                             headers->data);
          if(result)
            return result;
        }
      }
    }
    headers = headers->next;
  }
  return CURLE_OK;
}

2011/8/29 Daniel Stenberg <daniel_at_haxx.se>:
> It came through completely garbled. I couldn't read it, nor apply it. Please
> send it again, attached instead of lined.
>
>> So this "Content-Type: text/html; charset=utf 8;" never match. Because it
>> includes colon.
>
> Ah, then I'm sorry I must've misread it. It wasn't easy to figure out.

Regards,
Thank you.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-08-29