mirror of https://github.com/apache/jclouds.git
Issue 483:@VirtualHost annotation does not present port number
This commit is contained in:
parent
59e1097c7d
commit
5c1c731311
|
@ -441,8 +441,12 @@ public class RestAnnotationProcessor<T> {
|
||||||
if (r != null)
|
if (r != null)
|
||||||
headers.putAll(r.getHeaders());
|
headers.putAll(r.getHeaders());
|
||||||
|
|
||||||
if (shouldAddHostHeader(method))
|
if (shouldAddHostHeader(method)) {
|
||||||
headers.put(HOST, endpoint.getHost());
|
StringBuilder hostHeader = new StringBuilder(endpoint.getHost());
|
||||||
|
if (endpoint.getPort() != -1)
|
||||||
|
hostHeader.append(":").append(endpoint.getPort());
|
||||||
|
headers.put(HOST, hostHeader.toString());
|
||||||
|
}
|
||||||
|
|
||||||
Payload payload = null;
|
Payload payload = null;
|
||||||
HttpRequestOptions options = findOptionsIn(method, args);
|
HttpRequestOptions options = findOptionsIn(method, args);
|
||||||
|
|
|
@ -1811,7 +1811,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
assertEquals(request.getEndpoint().getPath(), "/1");
|
assertEquals(request.getEndpoint().getPath(), "/1");
|
||||||
assertEquals(request.getMethod(), HttpMethod.GET);
|
assertEquals(request.getMethod(), HttpMethod.GET);
|
||||||
assertEquals(request.getHeaders().size(), 2);
|
assertEquals(request.getHeaders().size(), 2);
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost"));
|
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999"));
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE),
|
assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE),
|
||||||
Collections.singletonList(dateService.rfc822DateFormat(date)));
|
Collections.singletonList(dateService.rfc822DateFormat(date)));
|
||||||
}
|
}
|
||||||
|
@ -1825,7 +1825,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
assertEquals(request.getEndpoint().getPath(), "/1");
|
assertEquals(request.getEndpoint().getPath(), "/1");
|
||||||
assertEquals(request.getMethod(), HttpMethod.GET);
|
assertEquals(request.getMethod(), HttpMethod.GET);
|
||||||
assertEquals(request.getHeaders().size(), 2);
|
assertEquals(request.getHeaders().size(), 2);
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost"));
|
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999"));
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE),
|
assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE),
|
||||||
Collections.singletonList(dateService.rfc822DateFormat(date)));
|
Collections.singletonList(dateService.rfc822DateFormat(date)));
|
||||||
}
|
}
|
||||||
|
@ -1842,7 +1842,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
Method method = TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class);
|
Method method = TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class);
|
||||||
HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1", options });
|
HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1", options });
|
||||||
assertRequestLineEquals(request, "GET http://localhost:9999/1?prefix=1 HTTP/1.1");
|
assertRequestLineEquals(request, "GET http://localhost:9999/1?prefix=1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: localhost\n");
|
assertNonPayloadHeadersEqual(request, "Host: localhost:9999\n");
|
||||||
assertPayloadEquals(request, null, null, false);
|
assertPayloadEquals(request, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1879,7 +1879,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
HttpRequest request = factory(TestRequest.class).createRequest(method, "1", options);
|
HttpRequest request = factory(TestRequest.class).createRequest(method, "1", options);
|
||||||
|
|
||||||
assertRequestLineEquals(request, "PUT http://localhost:9999/1 HTTP/1.1");
|
assertRequestLineEquals(request, "PUT http://localhost:9999/1 HTTP/1.1");
|
||||||
assertNonPayloadHeadersEqual(request, "Host: localhost\n");
|
assertNonPayloadHeadersEqual(request, "Host: localhost:9999\n");
|
||||||
assertPayloadEquals(request, "foo", "application/unknown", false);
|
assertPayloadEquals(request, "foo", "application/unknown", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1938,7 +1938,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
assertEquals(request.getEndpoint().getPath(), "/1");
|
assertEquals(request.getEndpoint().getPath(), "/1");
|
||||||
assertEquals(request.getMethod(), HttpMethod.GET);
|
assertEquals(request.getMethod(), HttpMethod.GET);
|
||||||
assertEquals(request.getHeaders().size(), 1);
|
assertEquals(request.getHeaders().size(), 1);
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost"));
|
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface TestVirtualHost {
|
public interface TestVirtualHost {
|
||||||
|
@ -1961,7 +1961,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
assertEquals(request.getEndpoint().getPath(), "/1");
|
assertEquals(request.getEndpoint().getPath(), "/1");
|
||||||
assertEquals(request.getMethod(), HttpMethod.GET);
|
assertEquals(request.getMethod(), HttpMethod.GET);
|
||||||
assertEquals(request.getHeaders().size(), 1);
|
assertEquals(request.getHeaders().size(), 1);
|
||||||
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost"));
|
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue