cURL / Mailing Lists / curl-users / Single Mail


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

From: David Houlder <>
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
>>> > curl --form-file name=filename
> 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
cd tests/
make test

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

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

David Houlder
61 Sherbrooke St
+61 2 6248 7463 (h)
+61 2 6125 0578 (w)

Received on 2005-03-12