Skip to content

Commit

Permalink
Use requestHTTP() for the HTTP request example. Fixes #374.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Nov 5, 2013
1 parent 5fd07cf commit 6328fee
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions examples/http_request/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import vibe.http.client;

void main()
{
auto client = new HTTPClient;
client.connect("www.google.com", 80);

auto res = client.request((req){
requestHTTP("http://www.google.com/",
(req) {
req.url = "/";
});

logInfo("Response: %d", res.statusCode);
foreach (k, v; res.headers)
logInfo("Header: %s: %s", k, v);

(new NullOutputStream).write(res.bodyReader);
client.disconnect();
},
(res) {
logInfo("Response: %d", res.statusCode);
foreach (k, v; res.headers)
logInfo("Header: %s: %s", k, v);
}
);
}

0 comments on commit 6328fee

Please sign in to comment.