cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: <warp.kawada_at_gmail.com>
Date: Thu, 25 Aug 2011 04:39:15 +0000

Hello

warp.kawada_at_gmail.com:
> curl -v -k -X POST -H 'X-Custom;' http://to/

> the header terminated by semicolon.

If you would use this spec then its patch is below.
How about this?

Regards,
Yukihiro KAWADA

===
diff --git a/lib/http.cb/lib/http.c
index edf3e16..d72d4fd 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1522,6 +1522,7 @@ CURLcode Curl_add_custom_headers(struct connectdata
*conn,
{
char *ptr;
struct curl_slist *headers=conn->data->set.headers;
+ CURLcode result;

while(headers) {
ptr = strchr(headers->data, ':');
@@ -1555,7 +1556,20 @@ CURLcode Curl_add_custom_headers(struct connectdata
*conn,
checkprefix("Connection", headers->data))
;
else {
- CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n",
+ 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;
===

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-08-25