use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestWithAbsoluteURIAsPath.
@Test
public void testRequestWithAbsoluteURIAsPath() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "https://host:9443/stuff?param=value");
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/stuff?param=value", httpRequestWrapper.getPath());
Assertions.assertEquals(new URIAuthority("host", 9443), httpRequestWrapper.getAuthority());
Assertions.assertEquals("https", httpRequestWrapper.getScheme());
Assertions.assertEquals(new URI("https://host:9443/stuff?param=value"), httpRequestWrapper.getUri());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestHostWithReservedChars.
@Test
public void testRequestHostWithReservedChars() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, URI.create("http://someuser%21@%21example%21.com/stuff"));
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/stuff", httpRequestWrapper.getPath());
Assertions.assertEquals(new URIAuthority("someuser%21", "%21example%21.com", -1), httpRequestWrapper.getAuthority());
Assertions.assertEquals(new URI("http://%21example%21.com/stuff"), httpRequestWrapper.getUri());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class HttpRequestWrapperTest method testRequestWithAuthority.
@Test
public void testRequestWithAuthority() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new HttpHost("http", "somehost", -1), "/stuff");
final HttpRequestWrapper httpRequestWrapper = new HttpRequestWrapper(request);
Assertions.assertEquals(Method.GET.name(), httpRequestWrapper.getMethod());
Assertions.assertEquals("/stuff", httpRequestWrapper.getPath());
Assertions.assertEquals(new URIAuthority("somehost"), httpRequestWrapper.getAuthority());
Assertions.assertEquals(new URI("http://somehost/stuff"), httpRequestWrapper.getUri());
httpRequestWrapper.setAuthority(new URIAuthority("newHost"));
Assertions.assertEquals(new URIAuthority("newHost"), httpRequestWrapper.getAuthority());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestStandardInterceptors method testRequestHttpHostHeaderNoPort.
@Test
public void testRequestHttpHostHeaderNoPort() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/");
request.setVersion(HttpVersion.HTTP_1_1);
request.setHeader(HttpHeaders.HOST, "host");
final RequestValidateHost interceptor = new RequestValidateHost();
interceptor.process(request, request.getEntity(), context);
Assertions.assertEquals(new URIAuthority("host"), request.getAuthority());
}
use of org.apache.hc.core5.net.URIAuthority in project httpcomponents-core by apache.
the class TestStandardInterceptors method testRequestHttpHostHeader.
@Test
public void testRequestHttpHostHeader() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final BasicClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, "/");
request.setVersion(HttpVersion.HTTP_1_1);
request.setHeader(HttpHeaders.HOST, "host:8888");
final RequestValidateHost interceptor = new RequestValidateHost();
interceptor.process(request, request.getEntity(), context);
Assertions.assertEquals(new URIAuthority("host", 8888), request.getAuthority());
}
Aggregations