use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testGetServerPort.
@Test
public void testGetServerPort() throws Exception {
URI uri = URI.create("http://example.yahoo.com/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(request.getServerPort(), 80);
request.setUri(URI.create("https://example.yahoo.com/test"));
Assert.assertEquals(request.getServerPort(), 443);
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testGetHeadersAsList.
@Test
public void testGetHeadersAsList() {
URI uri = URI.create("http://localhost:8080/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(request.getHeaderNamesAsList() instanceof List, true);
Assert.assertEquals(request.getHeaderNamesAsList().size(), 0);
httpReq.headers().add("header_1", "value1");
httpReq.headers().add("header_1", "value2");
Assert.assertEquals(request.getHeadersAsList("header_1").size(), 2);
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testParameterAPI.
@Test
public void testParameterAPI() {
URI uri = URI.create("http://example.yahoo.com:8080/test?param1=abc¶m2=xyz¶m2=pqr");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(request.getParameter("param1"), "abc");
Enumeration<String> values = request.getParameterValues("param2");
List<String> valuesList = Collections.list(values);
Assert.assertEquals(valuesList.get(0), "xyz");
Assert.assertEquals(valuesList.get(1), "pqr");
Enumeration<String> paramNames = request.getParameterNames();
List<String> paramNamesList = Collections.list(paramNames);
Assert.assertEquals(paramNamesList.size(), 2);
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testIsSecure.
@Test
public void testIsSecure() throws Exception {
URI uri = URI.create("http://example.yahoo.com/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(request.isSecure(), false);
request.setUri(URI.create("https://example.yahoo.com/test"));
Assert.assertEquals(request.isSecure(), true);
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class EmptyRequestFilterTestCase method requireThatEmptyFilterDoesNothing.
@Test
public void requireThatEmptyFilterDoesNothing() throws Exception {
final HttpRequest lhs = newRequest(Method.GET, "/status.html", Version.HTTP_1_1);
final HttpRequest rhs = newRequest(Method.GET, "/status.html", Version.HTTP_1_1);
EmptyRequestFilter.INSTANCE.filter(rhs, mock(ResponseHandler.class));
assertEquals(lhs.headers(), rhs.headers());
assertEquals(lhs.context(), rhs.context());
assertEquals(lhs.getTimeout(TimeUnit.MILLISECONDS), rhs.getTimeout(TimeUnit.MILLISECONDS));
assertEquals(lhs.parameters(), rhs.parameters());
assertEquals(lhs.getMethod(), rhs.getMethod());
assertEquals(lhs.getVersion(), rhs.getVersion());
assertEquals(lhs.getRemoteAddress(), rhs.getRemoteAddress());
}
Aggregations