Skip to content

Commit

Permalink
Add HTTP Host header to support Docker v1.12 (#1550)
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Loriedo <mloriedo@redhat.com>
  • Loading branch information
l0rd authored and Alexander Garagatyi committed Jun 23, 2016
1 parent db49b31 commit 14e6d4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ protected DockerResponse request(String method, String path, String query, List<
for (Pair<String, ?> header : headers) {
connection.setRequestProperty(header.first, String.valueOf(header.second));
}
String host = url.getHost();
if (url.getPort() != -1) {
host += ":" + Integer.toString(url.getPort());
}
// Host header is mandatory in HTTP 1.1
connection.setRequestProperty("Host", host);
if (entity != null) {
connection.setDoOutput(true);
try (OutputStream output = connection.getOutputStream()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ private void writeHttpHeaders(OutputStream output, String method, String path, S
writer.write(String.valueOf(header.second));
writer.write("\r\n");
}
writer.write("\r\n");
// Host header is mandatory in HTTP 1.1
writer.write("Host: \r\n\r\n");
writer.flush();
}

Expand Down

0 comments on commit 14e6d4a

Please sign in to comment.