cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: curl adds 0a(line feed) and 0d(CR) when doing an HTTP POST

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 25 Jan 2002 10:27:20 +0100 (MET)

On Thu, 24 Jan 2002, Pedro Neves wrote:

> When I type the following command:
> curl -# -H Content-Type: --data-ascii "mtu inside 1200" -u uall:uall
> http://16.152.1.28:80/config
> curl will add the following symbols:
> 0d(CR)
> 0a(line feed)
> to the HTTP POST.

Yes it does. I've totally forgotten why it does this. I recall that I added
that once upon the time due to some server or something that caused us
problems if we didn't...!

But that was like four years ago or so and I just can't remember any details.

> When I type the following command:
> curl -# -u uall:uall -H Content-Type: --data-binary @configmtu.txt
> http://16.152.1.28:80/config
> curl will add the following symbol:
> 0a(line feed)
> to the HTTP POST.

Are you quite sure of this? I can't see anything in the code that differs.
Both cases add "\r\n" to the end of the posted data, which would be CRLF,
0d0a.

> Is there any way to avoid this behaviour ?

Not without changing source code.

> If not, could you point me to the code that I would have to change to
> achieve this.

I'd recommend the patch below.

Can anyone come up with a good reason why these extra bytes were added in the
first place?

--- http.c 2002/01/16 14:47:00 1.85
+++ http.c 2002/01/25 09:20:50
@@ -935,12 +935,11 @@
           add_buffer(req_buffer, "\r\n", 2);
           add_buffer(req_buffer, data->set.postfields,
                      data->set.postfieldsize);
- add_buffer(req_buffer, "\r\n", 2);
         }
         else {
           add_bufferf(req_buffer,
                       "\r\n"
- "%s\r\n",
+ "%s",
                       data->set.postfields );
         }
       }

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-01-25