use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestAbsoluteRequestUri.
@Test
public void testRequestAbsoluteRequestUri() throws Exception {
final BasicHttpRequest request = new BasicHttpRequest(Method.GET, new HttpHost("http", "somehost", -1), "stuff");
Assertions.assertEquals("stuff", request.getRequestUri());
request.setAbsoluteRequestUri(true);
Assertions.assertEquals("http://somehost/stuff", request.getRequestUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestWithAbsoluteURI.
@Test
public void testRequestWithAbsoluteURI() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, new URI("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());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestHostWithReservedChars.
@Test
public void testRequestHostWithReservedChars() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, URI.create("http://someuser%21@%21example%21.com/stuff"));
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("/stuff", request.getPath());
Assertions.assertEquals(new URIAuthority("someuser%21", "%21example%21.com", -1), request.getAuthority());
Assertions.assertEquals(new URI("http://%21example%21.com/stuff"), request.getUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestBasicMessages method testRequestBasics.
@Test
public void testRequestBasics() throws Exception {
final HttpRequest request = new BasicHttpRequest(Method.GET, "/stuff");
Assertions.assertEquals(Method.GET.name(), request.getMethod());
Assertions.assertEquals("/stuff", request.getPath());
Assertions.assertNull(request.getAuthority());
Assertions.assertEquals(new URI("/stuff"), request.getUri());
}
use of org.apache.hc.core5.http.message.BasicHttpRequest in project httpcomponents-core by apache.
the class TestRequestHandlerRegistry method testResolveByHostnameAndRequestUri.
@Test
public void testResolveByHostnameAndRequestUri() throws Exception {
handlerRegistry.register("myhost", "/test*", "stuff");
Assertions.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest(Method.GET, new HttpHost("myhost"), "/test"), context));
Assertions.assertEquals("stuff", handlerRegistry.resolve(new BasicHttpRequest(Method.GET, new HttpHost("MyHost"), "/testabc"), context));
}
Aggregations