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: <Will.Hanson_at_equifax.com>
Date: Wed, 7 Sep 2011 11:46:03 -0400

I applied the Dan's patch to lib/http.c (version 7.21.7). While it did what it was designed to do regarding lines with semi-colons, something else was needed.

Instead I developed the following patch for lib/http.c :

If someone could add a curl_easy_setopt for this setting, it would be useful and appreciated.
The idea is to modify the POST / HTTP/1.1 to say POST ANYTHING HTTP/1.1 and letting cURL decide the HTTP string.
This ability accommodates web servers that utilize the POST PATH to decide what to do versus using the URL.

Code:

1619a1620
> char *curl_post_path; /* For getenv CURL_POST_PATH */ /* WKH 20110906 */
2065,2066c2066,2074
< else
< result = Curl_add_buffer(req_buffer, ppath, strlen(ppath));
---
> else {
> curl_post_path=getenv("CURL_POST_PATH");
> if (curl_post_path!=NULL)
> {
> result = Curl_add_buffer(req_buffer, curl_post_path, strlen(curl_post_path)); /* WKH 20110906 */
> } else {
> result = Curl_add_buffer(req_buffer, ppath, strlen(ppath)); /* WKH 20110906 */
> };
> };


Example env setting: CURL_POST_PATH="/COKE"

Is there a possibility this change (or equivalent) could make it into a future release? If so, any idea which one and when?
Thanks to everyone for their help. It is greatly appreciated.

Will Hanson


Inactive hide details for Dan Fandrich ---09/06/2011 02:18:57 PM---On Tue, Sep 06, 2011 at 11:47:43AM +0900, warp kawada wrote:Dan Fandrich ---09/06/2011 02:18:57 PM---On Tue, Sep 06, 2011 at 11:47:43AM +0900, warp kawada wrote:



          Dan Fandrich <dan@coneharvesters.com>
          Sent by: curl-library-bounces@cool.haxx.se

          09/06/2011 02:14 PM

          Please respond to
          libcurl development <curl-library@cool.haxx.se>

To

curl-library@cool.haxx.se

cc


Subject

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

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

This message contains information from Equifax Inc. which may be confidential and privileged. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify by e-mail postmaster@equifax.com.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

graycol.gif pic13977.gif ecblank.gif
Received on 2011-09-07