cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 6 Sep 2011 11:14:19 -0700

On Tue, Sep 06, 2011 at 11:47:43AM +0900, warp kawada wrote:
> I've modified my codes.
> How about this?
> This patch file is attached.
>
> diff --git a/lib/http.c b/lib/http.c
> index b673296..a312c61 100644
> --- a/lib/http.c
> +++ b/lib/http.c
> @@ -1559,6 +1559,27 @@ CURLcode Curl_add_custom_headers(struct
> connectdata *conn,
> }
> }
> }
> + ptr = strchr(headers->data, ';');

I think you want this whole patch to be in an 'else' block
here. Otherwise, a header like "X-Test: foo; " would be sent twice; once
as a normal header and once as an empty header (with the semicolon converted
to a colon). That would actually a good case to add to the test suite.

> + if(ptr) {
> +
> + ptr++; /* pass the semicolon */
> + while(*ptr && ISSPACE(*ptr))
> + ptr++;
> +
> + if(*ptr) {
> + /* this may be used for something else in the future */
> + }
> + else {
> + if (*(--ptr) == ';') {
> + /* send no-value custom header if terminated by semicolon */
> + *ptr = ':';
> + result = Curl_add_bufferf(req_buffer, "%s\r\n",
> + headers->data);
> + if(result)
> + return result;
> + }
> + }
> + }
> headers = headers->next;

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-06