cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to send a form field value that begins with '@'?

From: David Houlder <david.houlder_at_anu.edu.au>
Date: Sat, 12 Mar 2005 23:28:12 +1100

Daniel Stenberg wrote:
> On Fri, 4 Mar 2005, david houlder wrote:
>
>>> > curl --form-string name=@string http://somewhere.org
>>> > curl --form-file name=filename http://somewhere.org
...
>
> Anyone up to writing a patch for this?

Here it is!

Attached is a patch to implement the --form-string option. It's got a
.bin suffix purely so that it gets sent as application/octet-stream to
preserve some trailing ^M chars on some of the lines (modified test
case). Careful you don't mangle it. Length should be 6354.

After a little thought I figured there was no need to add --form-file,
as that would be exactly the same as --form name=@file, and there's no
possibility of misinterpreting or fooling that.

I've added --form-string to the options, help text and man page,
modified formparse() a bit, added a paragraph to docs/MANUAL, and
modified test39 to exercise the changes.

While I was at it I fixed a lurking bug in the option parsing -
subletter was not reset when a short option was encountered, leading to
a possibly erroneous switch on subletter (e.g. '--cacert xxx -E yyyy'
would be interpreted as '--cacert xxx -cacert yyyy'). Well, that's my
reading of it anyway.

To apply and test the patch I did this:

cd curl-7.13.2-20050310/
patch -p1 < ../curl-form-string.patch.bin
./configure
make
cd tests/
make test

and got
TESTDONE: 252 tests out of 252 reported OK: 100%

(nice test mechanism, btw!)
Cheers and thanks,
David.

-- 
David Houlder
61 Sherbrooke St
AINSLIE ACT 2602
Australia
+61 2 6248 7463 (h)
+61 2 6125 0578 (w)
david.houlder_at_anu.edu.au
http://davidhoulder.com

Received on 2005-03-12