use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestStandardInterceptors method testRequestTargetHostConnectHttp10.
@Test
public void testRequestTargetHostConnectHttp10() throws Exception {
final HttpContext context = new BasicHttpContext(null);
context.setProtocolVersion(HttpVersion.HTTP_1_0);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.CONNECT, "/");
request.setAuthority(new URIAuthority("somehost", 8080));
final HttpRequestInterceptor interceptor = RequestTargetHost.INSTANCE;
interceptor.process(request, request.getEntity(), context);
final Header header = request.getFirstHeader(HttpHeaders.HOST);
Assertions.assertNull(header);
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestWithAuthority.
@Test
public void testRequestWithAuthority() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new HttpHost("http", "somehost", -1), "/stuff");
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("/stuff", request.getPath());
Assertions.assertEquals(new URIAuthority("somehost"), request.getAuthority());
Assertions.assertEquals(new URI("http://somehost/stuff"), request.getUri());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestWithAuthorityRelativePath.
@Test
public void testRequestWithAuthorityRelativePath() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new HttpHost("http", "somehost", -1), "stuff");
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("stuff", request.getPath());
Assertions.assertEquals(new URIAuthority("somehost"), request.getAuthority());
Assertions.assertEquals(new URI("http://somehost/stuff"), request.getUri());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestWithUserInfo.
@Test
public void testRequestWithUserInfo() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new URI("https://user:pwd@host:9443/stuff?param=value"));
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("/stuff?param=value", request.getPath());
Assertions.assertEquals(new URIAuthority("user:pwd", "host", 9443), request.getAuthority());
Assertions.assertEquals("https", request.getScheme());
Assertions.assertEquals(new URI("https://host:9443/stuff?param=value"), request.getUri());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestWithAbsoluteURIAsPath.
@Test
public void testRequestWithAbsoluteURIAsPath() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "https://host:9443/stuff?param=value");
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("/stuff?param=value", request.getPath());
Assertions.assertEquals(new URIAuthority("host", 9443), request.getAuthority());
Assertions.assertEquals("https", request.getScheme());
Assertions.assertEquals(new URI("https://host:9443/stuff?param=value"), request.getUri());
}
Aggregations