cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: multiple POST requests while reusing the TCP connection

From: JustAn0therAcc0unt <mailnew4ster_at_gmail.com>
Date: Thu, 07 Nov 2013 22:57:19 +0200

On 07.11.2013 16:02, Daniel Stenberg wrote:
> On Wed, 6 Nov 2013, JustAn0therAcc0unt . wrote:
>
>> For example:
>> curl -o 1.jpg http://example.com/1.jpg -o 2.jpg http://example.com/2.jpg
>>
>> I need to do the same, but with different post queries to the same URL.
>>
>> I thought maybe this would work:
>> curl -d "a=1" -o 1 http://example.com/script.php -d "a=2" -o 2
>> http://example.com/script.php
>>
>> But instead of separating the -d arguments per request, it just adds them
>> together.
>>
>> Is there any way to achieve what I want with cURL?
>
> Nope. We've previously discussed adding that ability but so far we haven't.
>

I think such an option can be very helpful in multiple scenarios. And
not only for post fields, but for other switches such as cookies or
referer, too.

I haven't looked at the source code of cURL, but I assume it works like
the following: first it parses the command line switches, saves the
options to variables, and then executes the requests.

I suggest changing the strategy to the following: parse the command line
arguments until an URL is met, make a request with what you've got so
far, then continue parsing until you see a second URL (overwriting any
options, not appending), and so on. Then, the command line I suggested
in my first message will work.

Of course, such workflow is not backwards compatible, so you might want
to introduce a command line switch to change it, e.g.
--new-cmdline-parsing (which will probably have to be the first switch).
Or you might want to introduce it in a major release.

Anyhow, I think introducing such an option will provide greater
flexibility and will allow to achieve what is currently achievable only
by working with the cURL library directly.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-11-07