From 9620389e5aae986d055c445588969baf7e122279 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Fri, 1 Jun 2012 11:31:07 +0200 Subject: [PATCH] Set port in the request header from the endpoint --- .../http/internal/JavaUrlHttpCommandExecutorService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index 1fec2a79c8..e544b2a4e6 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -209,7 +209,12 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe connection.setRequestProperty(header, value); } } - connection.setRequestProperty(HttpHeaders.HOST, request.getEndpoint().getHost()); + + String host = request.getEndpoint().getHost(); + if(request.getEndpoint().getPort() != -1) { + host += ":" + request.getEndpoint().getPort(); + } + connection.setRequestProperty(HttpHeaders.HOST, host); connection.setRequestProperty(HttpHeaders.USER_AGENT, USER_AGENT); if (request.getPayload() != null) {