cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: curl --form problem

From: Luca Arzeni <l.arzeni_at_amadego.com>
Date: Mon, 10 May 2004 11:55:22 +0200

On Monday 10 May 2004 10:29, you wrote:
> On Mon, 10 May 2004, Luca Arzeni wrote:
> > I tempted also with the http clear text (no SSL) invocation, following
> > the hint that some users gave me:
> >
> > curl --form "INPUT_XML=<somefile.xml"
> > http://localhost:8080/CWS/GPGAuthentication/ServiceManager
> >
> > and I actually tested the it does NOT works; so I'm sure that the problem
> > is not in the protocol, but in curl.
>
> What makes you say this? How do you expect this to send the data and in
> what way does curl fail to do so? I syggest you try --trace or
> --trace-ascii to get a full dump of exact what bytes curl sends/receives.
>
> > Just to be sure I tested:
> >
> > curl --data "INPUT_XML=sometext"
> > http://localhost:8080/CWS/GPGAuthentication/ServiceManager
> >
> > And this time the system works fine.
>
> So why are you using --form when --data is what you want?

Thanks for your help,

I will explain better my problem:

I would like to send a string, in the input parameter INPUT_XML, and I would
like to read the string content from a file (I mean that the content of
somefile.xml is sometext). I thought I need to encode the content of the file
to avoid problems when sending it as post parameter (in my understanding this
job was done by the --form option and not by the --data option).

I am using the two different invocation (--data and --form) to see that the
problem is not in the server-side code, but in the caller, since I can read
the parameter when it comes with --data but not when it comes with --form.

According to your suggestion I tried the --trace-ascii option and the output
showed me that indeed curl is passing the data:

== Info: About to connect() to localhost port 8080
== Info: Connected to localhost (127.0.0.1) port 8080
=> Send header, 328 bytes (0x148)
0000: POST /CWS/GPGAuthentication/ServiceManager HTTP/1.1
....
002c: Content-Disposition: form-data; name="INPUT_XML"
005e:
0060: ...data is here...
038c: ------------------------------1cdf1e097e0f--
<= Recv header, 17 bytes (0x11)
0000: HTTP/1.1 200 OK

So curl is working fine; the problem is that I misunderstood the manual, and
indeed I must use --data instead of --form; but I miss the url-encoding
feature in the --data invocation.

I also have a little suggestion for curl:
When I send a parameter, this is done with --data "NAME=value"; the same
happens when I send a file using --form "NAME=<filepath".

I would expect that this would be the same way that I send a file using
--data, that is --data "INPUT-XML=@filepath". Instead I must change the file
pointed by filepath putting at the top of the file the NAME of the parameter
that I must pass.

Anyway, thank you very much indeed for your help, it solved the problem.

Regards, Luca
Received on 2004-05-10