cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Send an empty header field

From: Gara Peter <havetheblues_at_freemail.hu>
Date: Mon, 12 Jan 2004 10:41:23 +0100 (CET)

Dear Torsten,

Thank you for your answer. Since I didn't need to eliminate headers, I
changed the code in the following way:

curl-7.10.8/lib/http.c (original part of code):

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

        add_bufferf(req_buffer, "%s\r\n", headers->data);
        }

curl-7.10.8/lib/http.c (modified code):

add_bufferf(req_buffer, "%s\r\n", headers->data);

-----------------------------------------------------------------

I eliminated the 'if' statement. It wasn't elegant but was very useful for
my test application.

Best regards,

Peter

Torsten Foertsch <torsten.foertsch_at_gmx.net> írta:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Here is a not very elegant patch:
>
> - --- curl-7.10.8/lib/http.c 2003-10-31 22:43:22.000000000 +0100
> +++ curl-7.10.8.new/lib/http.c 2004-01-10 18:26:44.000000000
+0100
> @@ -1420,6 +1420,8 @@
>
> add_bufferf(req_buffer, "%s\r\n", headers->data);
> }
> + } else {
> + add_bufferf(req_buffer, "%s: \r\n", headers->data);
> }
> headers = headers->next;
> }
>
> with the following effect.
>
> curl -H Host: -- deletes the Host: header as yet
> curl -H Host -- (without the colon) creates an empty header
> curl -H SomeHeader -- creates an empty header
>
> Here an example:
>
> # (src/curl -sv -H klaus:\ otto -H klaus -H Host -H Host: -H Host:\
heinz http://localhost >/dev/null) 2>&1 | cat -n
> 1 * About to connect() to localhost:80
> 2 * socket error
> 3 * Connected to localhost (127.0.0.1) port 80
> 4 > GET / HTTP/1.1
> 5 User-Agent: curl/7.10.8 (i686-pc-linux-gnu) libcurl/7.10.8
OpenSSL/0.9.6g ipv6 zlib/1.1.4
> 6 Pragma: no-cache
> 7 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
*/*
> 8 klaus: otto
> 9 klaus:
> 10 Host:
> 11 Host: heinz
> 12
>
> The "-H klaus:\ otto" creates line 8, "-H klaus" line 9, "-H Host"
creates
> line 10, "-H Host:" deletes the normal "Host: localhost" header and
> "-H Host:\ heinz" creates line 11.
>
> Was that your problem?
>
> Torsten
>
> On Friday 09 January 2004 17:51, Gara Peter wrote:
> > It was a unique problem. I had to test an application, which used
tricky
> > communication with customized header fields. Sometimes it used
empty
> > header fields, in order that I should have to solve the checking of
> > those situations.
> >
> > Daniel Stenberg <daniel-curl_at_haxx.se> írta:
> > > On Thu, 8 Jan 2004, Gara Peter wrote:
> > > > Thank you for your answer. I had tried to use extra spaces, but
curl
> >
> > had
> >
> > > > ignored them. So I downloaded the source code and modified
the
> >
> > relevant part
> >
> > > > of it to run the desired function. It was successful.
> > >
> > > Did you come up with a good approach for doing this that might
be
> >
> > worth
> >
> > > sharing with the rest of us?
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
>
>
iD8DBQFAAD0nwicyCTir8T4RAmdnAJsEUWb02sflh9VjXB4x8s1mcPkkFACfc
1E4
> thCJNWXhCWmds6LYw4npadw=
> =abFp
> -----END PGP SIGNATURE-----
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Perforce Software.
> Perforce is the Fast Software Configuration Management System
offering
> advanced branching capabilities and atomic changes on 50+
platforms.
> Free Eval! http://www.perforce.com/perforce/loadprog.html
>
>
>

-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
Received on 2004-01-12