View mode: basic / threaded / horizontal-split · Log in · Help
July 24, 2012
std.net.curl - HTTP.Method.options - perform()
Hello!

Why does this code print output when I run it?
   - It only happens when the HTTP response Code is == 405
   - 173.194.69.94 is a Google Server for testing
   - Are there any default callbacks which make this output?

CODE:

http://pastebin.com/CZP86Gwh

OUTPUT:

http://pastebin.com/AkA3Fvw1 (Basically a HTML error page)

--Alex
July 27, 2012
Re: std.net.curl - HTTP.Method.options - perform()
On Tuesday, 24 July 2012 at 16:45:49 UTC, Alex wrote:
> Hello!
>
> Why does this code print output when I run it?
>    - It only happens when the HTTP response Code is == 405
>    - 173.194.69.94 is a Google Server for testing
>    - Are there any default callbacks which make this output?
>
> CODE:
>
> http://pastebin.com/CZP86Gwh
>
> OUTPUT:
>
> http://pastebin.com/AkA3Fvw1 (Basically a HTML error page)
>
> --Alex

There must be a default onReceive that is writing that to stdout. 
If I add this line just before the perform() call the output is 
not generated:

http.onReceive = (ubyte[] data) { /+ drop +/ return data.length; 
};

-David
July 27, 2012
Re: std.net.curl - HTTP.Method.options - perform()
Am Fri, 27 Jul 2012 17:39:45 +0200
schrieb "David Eagen" <davideagen@mailinator.com>:

> 
> There must be a default onReceive that is writing that to stdout. 
> If I add this line just before the perform() call the output is 
> not generated:
> 
> http.onReceive = (ubyte[] data) { /+ drop +/ return data.length; 
> };
> 
> -David

I just had a quick look an this is not caused by the D interface. It's
the default behavior of libcurl if no explicit callback is set.

If desired we could add some code to the wrapper's initialize function
to automatically set this callback to a dummy function, but silently
dropping the data doesn't sound much better to me.

-------------
Set this option to NULL to get the internal default function. The
internal default function will write the data to the FILE * given with
CURLOPT_WRITEDATA.
-------------
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPT_WRITEFUNCTION

-------------
The internal CURLOPT_WRITEFUNCTION will write the data to the FILE *
given with this option, or to stdout if this option hasn't been set. 
-------------
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA
Top | Discussion index | About this forum | D home