On 12/01/2014 10:25 AM, Suliman wrote:

> why:
>      string link = "dlang.org";
>      writeln(connect(link));
>
> cause crash:

(To be pedantic: An unhandled exception is not a crash. ;) )

> std.net.curl.CurlException@C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\net\curl
>
> .d(779): HTTP request returned status code 400

Indeed, the following program does behave in the same way:

import std.stdio;
import std.net.curl;

pragma(lib, "curl");

void main()
{
    string link = "dlang.org";
    writeln(connect(link));
}

I have very little experience with the HTTP protocol and its methods but I've just learnt that connect() is for HTTP's CONNECT method, which is most likely supported on port 443.

So, I tried

    string link = "dlang.org:443";

and got

std.net.curl.CurlException@std/net/curl.d(3684): Server returned nothing (no headers, no data) on handle 198F860

So, that's an improvement I guess. (It was the same result at "google.com:443") Then I tried HTTPS explicitly:

    string link = "https://dlang.org:443";;

Now the error message is more promising:

std.net.curl.CurlException@std/net/curl.d(3684): Peer certificate cannot be authenticated with known CA certificates on handle 1653860

My guess is that you have to use HTTPS for CONNECT and that you have to have credentials for it. (?)

Ali

Reply via email to