Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide port information when the HTTP request isn't on the default port #1510

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions source/vibe/http/client.d
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ HTTPClientResponse requestHTTP(URL url, scope void delegate(scope HTTPClientRequ
}
if (settings.proxyURL.schema !is null)
req.requestURL = url.toString(); // proxy exception to the URL representation
req.headers["Host"] = url.host;

// Provide port number when it is not the default one (RFC2616 section 14.23)
if (url.port && url.port != url.defaultPort)
req.headers["Host"] = format("%s:%d", url.host, url.port);
else
req.headers["Host"] = url.host;

if ("authorization" !in req.headers && url.username != "") {
import std.base64;
string pwstr = url.username ~ ":" ~ url.password;
Expand Down Expand Up @@ -125,7 +131,13 @@ void requestHTTP(URL url, scope void delegate(scope HTTPClientRequest req) reque
}
if (settings.proxyURL.schema !is null)
req.requestURL = url.toString(); // proxy exception to the URL representation
req.headers["Host"] = url.host;

// Provide port number when it is not the default one (RFC2616 section 14.23)
if (url.port && url.port != url.defaultPort)
req.headers["Host"] = format("%s:%d", url.host, url.port);
else
req.headers["Host"] = url.host;

if ("authorization" !in req.headers && url.username != "") {
import std.base64;
string pwstr = url.username ~ ":" ~ url.password;
Expand Down