Skip to content

Commit

Permalink
Merge pull request #501 from nazriel/issue481
Browse files Browse the repository at this point in the history
Fix issue #481
  • Loading branch information
s-ludwig committed Feb 7, 2014
2 parents 824a752 + 1c33387 commit eb99eb0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source/vibe/http/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ HTTPClientResponse requestHTTP(URL url, scope void delegate(scope HTTPClientRequ
if (url.localURI.length)
req.requestURL = url.localURI;
req.headers["Host"] = url.host;
if ("authorization" !in req.headers && url.username != "") {
import std.base64;
string pwstr = url.username ~ ":" ~ url.password;
req.headers["Authorization"] = "Basic " ~
cast(string)Base64.encode(cast(ubyte[])pwstr);
}
if( requester ) requester(req);
});

Expand All @@ -94,6 +100,12 @@ void requestHTTP(URL url, scope void delegate(scope HTTPClientRequest req) reque
if (url.localURI.length)
req.requestURL = url.localURI;
req.headers["Host"] = url.host;
if ("authorization" !in req.headers && url.username != "") {
import std.base64;
string pwstr = url.username ~ ":" ~ url.password;
req.headers["Authorization"] = "Basic " ~
cast(string)Base64.encode(cast(ubyte[])pwstr);
}
if( requester ) requester(req);
}, responder);
assert(!cli.m_requesting, "HTTP client still requesting after return!?");
Expand Down

0 comments on commit eb99eb0

Please sign in to comment.