curl-library
Re: Problem regarding to post 0 content length data
Date: Tue, 22 Jul 2008 13:20:27 +0200 (CEST)
On Tue, 22 Jul 2008, Ajeet kumar.S wrote:
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, 0);
>
> Curl ask to input through keyboard(means one input window open to give
> the input using keyboard).
No, libcurl does not really "ask to input through keyboard". (see below)
You need to set the CURLOPT_POSTFIELDS to "" and not to zero.
> Here I want to sent no data. So I set given below option:
>
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "\0");
Right, this should work too but you'll of course "waste" an extra byte by
this.
> Then it is working not calling input window.
>
> Why if I was using 0 instead of "\0" in curl option it was showing input
> window for input through keyboard.
First, you need to understand that libcurl is not the cause for that window.
It is your silly operating system:
When you set CURLOPT_POSTFIELDS to NULL (NULL should be used when it is a
pointer, not 0) and still set the POST option you imply that libcurl will get
the contents of the POST by other means. This other means is the read
callback. The default read callback will read data from stdin. On some silly
systems (Windows is the only one I know that do this) they pop up a window for
this situation (there may be other factors involved too, I'm not really sure
of how this magic works or not).
But of course. You don't want to use the read callback so you should do that
in the first place. And if you did want to use the read callback, I doubt you
want to read the data from stdin. And if you did want to read from stdin, I
bet you even might like that it opened a windows so that you can provide data
there...
-- / daniel.haxx.seReceived on 2008-07-22