use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterResponseTest method testSetHeader.
@Test
public void testSetHeader() {
URI uri = URI.create("http://example.com/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
HttpResponse httpResp = newResponse(httpReq, 200);
DiscFilterResponse response = new JdiscFilterResponse(httpResp);
response.setHeader("name", "value");
Assert.assertEquals(response.getHeader("name"), "value");
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class EmptyResponseFilterTestCase method requireThatEmptyFilterDoesNothing.
@Test
public void requireThatEmptyFilterDoesNothing() throws Exception {
final HttpRequest request = newRequest(Method.GET, "/status.html", Version.HTTP_1_1);
final HttpResponse lhs = HttpResponse.newInstance(Response.Status.OK);
final HttpResponse rhs = HttpResponse.newInstance(Response.Status.OK);
EmptyResponseFilter.INSTANCE.filter(lhs, null);
assertEquals(lhs.headers(), rhs.headers());
assertEquals(lhs.context(), rhs.context());
assertEquals(lhs.getError(), rhs.getError());
assertEquals(lhs.getMessage(), rhs.getMessage());
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class HttpRequestFactoryTest method test.
@Test
public final void test() {
String noise = "query=a" + "\\" + "^{|}&other=madeit";
HttpServletRequest servletRequest = new MockRequest("http://yahoo.com/search?" + noise);
HttpRequest request = HttpRequestFactory.newJDiscRequest(new MockContainer(), servletRequest);
assertThat(request.getUri().getQuery(), equalTo(noise));
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class HttpRequestFactory method newJDiscRequest.
public static HttpRequest newJDiscRequest(CurrentContainer container, HttpServletRequest servletRequest) {
HttpRequest httpRequest = HttpRequest.newServerRequest(container, getUri(servletRequest), HttpRequest.Method.valueOf(servletRequest.getMethod()), HttpRequest.Version.fromString(servletRequest.getProtocol()), new InetSocketAddress(servletRequest.getRemoteAddr(), servletRequest.getRemotePort()), getConnection(servletRequest).getCreatedTimeStamp());
httpRequest.context().put(ServletRequest.JDISC_REQUEST_X509CERT, getCertChain(servletRequest));
return httpRequest;
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testGetHeaderNamesAsList.
@Test
public void testGetHeaderNamesAsList() {
URI uri = URI.create("http://localhost:8080/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
httpReq.headers().add(HttpHeaders.Names.CONTENT_TYPE, "multipart/form-data");
httpReq.headers().add("header_1", "value1");
httpReq.headers().add("header_2", "value2");
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(request.getHeaderNamesAsList() instanceof List, true);
Assert.assertEquals(request.getHeaderNamesAsList().size(), 3);
}
Aggregations