You can also use OpenSSL. I wrote a little wrapper class that extends std.socket.Socket for it:

https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/sslsocket.d


If you download that file and compile it with your app:

dmd yourfile.d sslsocket.d

you should be able to

import sslsocket.

void main() {
        auto sock = new OpenSslSocket(AddressFamily.INET);
        sock.connect(new InternetAddress("localhost", 443));
        sock.send("GET / HTTP/1.0\r\n\r\n");
        import std.stdio;
        char[1024] buffer;
        writeln(buffer[0 .. sock.receive(buffer)]);
}



which gets from a local https server. Or of course you can connect to other things too and use the raw socket.


If you want a wrapper library to do http, curl is one option

phobos wrapper:
http://dlang.org/phobos/std_net_curl.html

my old wrapper:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/curl.d

the key function on mine is:

string curl(string url, string data = null, string contentType = "application/x-www-form-urlencoded");

if you pass it a data string, it does a POST, otherwise it goes a GET on the url.



I've also written non-curl http clients (see http.d and http2.d in my github), a http server (see cgi.d, it doesn't do ssl itself but you can put it behind apache or nginx or IIS to get it from them), and some oauth code (oauth.d in there). If you need to know anything about them feel free to ask.

Reply via email to