License:
Version:
Author:
Author:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // callback for client reader void sink (void[] content) { Stdout (cast(char[]) content); } // create client for a GET request auto client = new HttpClient (HttpClient.Get, "http://www.yahoo.com"); // make request client.open; // check return status for validity if (client.isResponseOK) { // extract content length auto length = client.getResponseHeaders.getInt (HttpHeader.ContentLength); // display all returned headers Stdout (client.getResponseHeaders); // display remaining content client.read (&sink, length); } else Stderr (client.getResponse); client.close(); |