Igor Korot | 11 Jul 2012 21:38
Picon

libcurl: Windows vs Mac

Hi, ALL,
I am new to libcurl and trying to write cross-platform software having problem.

Here is my code:

CURLcode error;
char errorMsg[1024];
wxString boundary = wxString::Format( "---------------------------%x",
static_cast<unsigned int>( time( NULL ) ) );
curl_easy_setopt( handle, CURLOPT_URL,
"http://174.122.236.154/TouchAndRead/Default.aspx" );
curl_easy_setopt( handle, CURLOPT_POSTFIELDS, const_cast<char *>(
boundary.ToAscii().data() ) );
curl_easy_setopt( handle, CURLOPT_ERRORBUFFER, errorMsg );
error = curl_easy_perform( handle );

Running on Mac/Cocoa this executes fine. When ran on Windows however,
I am getting CURLE_WRITE_ERROR
and the errorMsg contains: "Failed writing body(1416 != 1460)".

Is there some option I'm missing to set for Windows? AFAIU,
CURLOPT_INFILESIZE_LARGE is for files only...

Thank you.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Guenter | 12 Jul 2012 01:06

Re: libcurl: Windows vs Mac

Hi Igor,
Am 11.07.2012 21:38, schrieb Igor Korot:
> I am new to libcurl and trying to write cross-platform software having problem.
>
> Here is my code:
>
> CURLcode error;
> char errorMsg[1024];
> wxString boundary = wxString::Format( "---------------------------%x",
> static_cast<unsigned int>( time( NULL ) ) );
> curl_easy_setopt( handle, CURLOPT_URL,
> "http://174.122.236.154/TouchAndRead/Default.aspx" );
> curl_easy_setopt( handle, CURLOPT_POSTFIELDS, const_cast<char *>(
> boundary.ToAscii().data() ) );
> curl_easy_setopt( handle, CURLOPT_ERRORBUFFER, errorMsg );
> error = curl_easy_perform( handle );
>
> Running on Mac/Cocoa this executes fine. When ran on Windows however,
> I am getting CURLE_WRITE_ERROR
> and the errorMsg contains: "Failed writing body(1416 != 1460)".
>
> Is there some option I'm missing to set for Windows? AFAIU,
> CURLOPT_INFILESIZE_LARGE is for files only...
if that is all of your code I dont see curl_easy_init() nor 
curl_easy_cleanup() ...
see here for a http post sample in C:
http://curl.haxx.se/libcurl/c/http-post.html

also you might have to call
curl_global_init(CURL_GLOBAL_WIN32);
(Continue reading)

Igor Korot | 12 Jul 2012 01:27
Picon

Re: libcurl: Windows vs Mac

Hi, Guenter,

On Wed, Jul 11, 2012 at 4:06 PM, Guenter <lists <at> gknw.net> wrote:
> Hi Igor,
> Am 11.07.2012 21:38, schrieb Igor Korot:
>
>> I am new to libcurl and trying to write cross-platform software having
>> problem.
>>
>> Here is my code:
>>
>> CURLcode error;
>> char errorMsg[1024];
>> wxString boundary = wxString::Format( "---------------------------%x",
>> static_cast<unsigned int>( time( NULL ) ) );
>> curl_easy_setopt( handle, CURLOPT_URL,
>> "http://174.122.236.154/TouchAndRead/Default.aspx" );
>> curl_easy_setopt( handle, CURLOPT_POSTFIELDS, const_cast<char *>(
>> boundary.ToAscii().data() ) );
>> curl_easy_setopt( handle, CURLOPT_ERRORBUFFER, errorMsg );
>> error = curl_easy_perform( handle );
>>
>> Running on Mac/Cocoa this executes fine. When ran on Windows however,
>> I am getting CURLE_WRITE_ERROR
>> and the errorMsg contains: "Failed writing body(1416 != 1460)".
>>
>> Is there some option I'm missing to set for Windows? AFAIU,
>> CURLOPT_INFILESIZE_LARGE is for files only...
>
> if that is all of your code I dont see curl_easy_init() nor
(Continue reading)

Guenter | 12 Jul 2012 01:42

Re: libcurl: Windows vs Mac

Hi Igor,
Am 12.07.2012 01:27, schrieb Igor Korot:
> Do I have to even if I use "curl_global_init();" without any parameters?
cant tell for sure; the curl commandline seems to use:
curl_global_init(CURL_GLOBAL_DEFAULT);
though strange that CURL_GLOBAL_DEFAULT is not mentioned here:
http://curl.haxx.se/libcurl/c/curl_global_init.html

> Both "curl_easy_init()" and "curl_global_init()" are done on the app
> initialization...
thats ok then.

But the known issue Dan just posted is probably more likely the cause ...

Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Dan Fandrich | 12 Jul 2012 01:22
Favicon

Re: libcurl: Windows vs Mac

On Wed, Jul 11, 2012 at 12:38:04PM -0700, Igor Korot wrote:
> Running on Mac/Cocoa this executes fine. When ran on Windows however,
> I am getting CURLE_WRITE_ERROR
> and the errorMsg contains: "Failed writing body(1416 != 1460)".

This error occurs when the write callback returns an error. Are
you setting a write callback? Are you setting any write data?
Windows has an issue with the default write callback due to
issues sharing DLLs (see the tutorial for more info).

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Igor Korot | 12 Jul 2012 01:35
Picon

Re: libcurl: Windows vs Mac

Hi, Dan,

On Wed, Jul 11, 2012 at 4:22 PM, Dan Fandrich <dan <at> coneharvesters.com> wrote:
> On Wed, Jul 11, 2012 at 12:38:04PM -0700, Igor Korot wrote:
>> Running on Mac/Cocoa this executes fine. When ran on Windows however,
>> I am getting CURLE_WRITE_ERROR
>> and the errorMsg contains: "Failed writing body(1416 != 1460)".
>
> This error occurs when the write callback returns an error. Are
> you setting a write callback? Are you setting any write data?
> Windows has an issue with the default write callback due to
> issues sharing DLLs (see the tutorial for more info).

No, I don't set any callback.Just using the code from the tutorial
at the beginning of HTTP Post section.

Thank you.

>
>>>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Guenter | 12 Jul 2012 01:53

Re: libcurl: Windows vs Mac

Am 12.07.2012 01:35, schrieb Igor Korot:
> No, I don't set any callback.Just using the code from the tutorial
> at the beginning of HTTP Post section.
try:
grep -R 'indows' docs/examples/*.c
to find some samples which have hints for Windows ...

Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Igor Korot | 12 Jul 2012 09:00
Picon

Re: libcurl: Windows vs Mac

Guys,

On Wed, Jul 11, 2012 at 4:53 PM, Guenter <lists <at> gknw.net> wrote:
> Am 12.07.2012 01:35, schrieb Igor Korot:
>
>> No, I don't set any callback.Just using the code from the tutorial
>> at the beginning of HTTP Post section.
>
> try:
> grep -R 'indows' docs/examples/*.c
> to find some samples which have hints for Windows ...

Following tutorial, I tried to insert:

curl_easy_setopt( handle, CURLOPT_VERBOSE, 1 );

However, I am running my program inside the IDE, where there is no console
window. There is an "Output" window, however, no protocol info is
going in there.

And there is no "Debug" window.

So just wondering which window in MSVC 2010 will hold the information
I'm looking
for.

Thank you.

>
> Gün.
(Continue reading)

Guenter | 12 Jul 2012 14:45

Re: libcurl: Windows vs Mac

Hi Igor,
Am 12.07.2012 09:00, schrieb Igor Korot:
> Following tutorial, I tried to insert:
>
> curl_easy_setopt( handle, CURLOPT_VERBOSE, 1 );
>
> However, I am running my program inside the IDE, where there is no console
> window. There is an "Output" window, however, no protocol info is
> going in there.
>
> And there is no "Debug" window.
>
> So just wondering which window in MSVC 2010 will hold the information
> I'm looking
> for.
I've not yet played with the MSVC 2010 IDE so I cant tell;
however the verbose output should go to STDERR, and I can catch it with 
IO redirection, f.e. with curl.exe on Windows I can do:
curl -v http://curl.haxx.se/ 2>verbose.txt
and get the verbose output in the file verbose.txt ...

HTH, Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Guenter | 12 Jul 2012 14:52

Re: libcurl: Windows vs Mac

Am 12.07.2012 14:45, schrieb Guenter:
> Am 12.07.2012 09:00, schrieb Igor Korot:
>> Following tutorial, I tried to insert:
>>
>> curl_easy_setopt( handle, CURLOPT_VERBOSE, 1 );
oh, and I forgot to mention: it should be:
curl_easy_setopt( handle, CURLOPT_VERBOSE, 1L );
as I suggested before: grep is your friend, and shows you such things:
grep -R 'CURLOPT_VERBOSE' docs/examples/*.c

Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Guenter | 12 Jul 2012 15:10

Re: libcurl: Windows vs Mac

Am 12.07.2012 14:52, schrieb Guenter:
> Am 12.07.2012 14:45, schrieb Guenter:
>> Am 12.07.2012 09:00, schrieb Igor Korot:
>>> Following tutorial, I tried to insert:
>>>
>>> curl_easy_setopt( handle, CURLOPT_VERBOSE, 1 );
> oh, and I forgot to mention: it should be:
> curl_easy_setopt( handle, CURLOPT_VERBOSE, 1L );
> as I suggested before: grep is your friend, and shows you such things:
> grep -R 'CURLOPT_VERBOSE' docs/examples/*.c
I've just addded the curl_global_* functions to this sample which also 
uses a read callback and sets CURLOPT_VERBOSE - so this should be a fine 
sample for you:
http://curl.haxx.se/libcurl/c/post-callback.html
also Daniel has added CURL_GLOBAL_DEFAULT to the docs:
http://curl.haxx.se/libcurl/c/curl_global_init.html

Gün.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Daniel Stenberg | 12 Jul 2012 15:43
Picon
Favicon
Gravatar

Re: libcurl: Windows vs Mac

On Thu, 12 Jul 2012, Guenter wrote:

> I've not yet played with the MSVC 2010 IDE so I cant tell;
> however the verbose output should go to STDERR, and I can catch it with IO 
> redirection, f.e. with curl.exe on Windows I can do:
> curl -v http://curl.haxx.se/ 2>verbose.txt
> and get the verbose output in the file verbose.txt ...

And I'll throw in two alternative approaches:

1) Use CURLOPT_STDERR to redirect it someplace else, or...

2) Use CURLOPT_DEBUGFUNCTION to handle it in your own callback!

--

-- 

  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Igor Korot | 13 Jul 2012 01:28
Picon

Re: libcurl: Windows vs Mac

Daniel,
Thank you. First option worked.

On Thu, Jul 12, 2012 at 6:43 AM, Daniel Stenberg <daniel <at> haxx.se> wrote:
> On Thu, 12 Jul 2012, Guenter wrote:
>
>> I've not yet played with the MSVC 2010 IDE so I cant tell;
>> however the verbose output should go to STDERR, and I can catch it with IO
>> redirection, f.e. with curl.exe on Windows I can do:
>> curl -v http://curl.haxx.se/ 2>verbose.txt
>> and get the verbose output in the file verbose.txt ...
>
>
> And I'll throw in two alternative approaches:
>
> 1) Use CURLOPT_STDERR to redirect it someplace else, or...
>
> 2) Use CURLOPT_DEBUGFUNCTION to handle it in your own callback!
>
> --
>
>  / daniel.haxx.se
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

(Continue reading)

Maxime Larocque | 12 Jul 2012 15:21
Picon
Favicon

Re: libcurl: Windows vs Mac

Igor,

Le 12/07/2012 03:00, Igor Korot a écrit :
> However, I am running my program inside the IDE, where there is no 
> console window. There is an "Output" window, however, no protocol info 
> is going in there. And there is no "Debug" window. So just wondering 
> which window in MSVC 2010 will hold the information I'm looking for. 
> Thank you.

I am not sure if it fits your case, by here it is anyways:

In MSVC, by default, printf are only displayed in console application, 
not in application with windows. If you are using an application with 
windows, you can use the OutputDebugString() function to display 
information in the debug section of MSVC. There are also ways to enable 
a console output with a windows application...

Regards,

Maxime
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Gmane