use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method requireThatUnresolvableRemoteAddressesAreSupported.
@Test
public void requireThatUnresolvableRemoteAddressesAreSupported() {
URI uri = URI.create("http://doesnotresolve.zzz:8080/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertNull(request.getLocalAddr());
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testAddCookie.
@Test
public void testAddCookie() {
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);
request.addCookie(JDiscCookieWrapper.wrap(new Cookie("name", "value")));
List<Cookie> cookies = request.getCookies();
Assert.assertEquals(cookies.size(), 1);
Assert.assertEquals(cookies.get(0).getName(), "name");
Assert.assertEquals(cookies.get(0).getValue(), "value");
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testGetUntreatedHeaders.
@Test
public void testGetUntreatedHeaders() {
URI uri = URI.create("http://example.yahoo.com/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
httpReq.headers().add("key1", "value1");
httpReq.headers().add("key2", Arrays.asList("value1", "value2"));
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
HeaderFields headers = request.getUntreatedHeaders();
Assert.assertEquals(headers.keySet().size(), 2);
Assert.assertEquals(headers.get("key1").get(0), "value1");
Assert.assertEquals(headers.get("key2").get(0), "value1");
Assert.assertEquals(headers.get("key2").get(1), "value2");
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testGetWrapedCookies.
@Test
public void testGetWrapedCookies() throws Exception {
URI uri = URI.create("http://example.yahoo.com/test");
HttpRequest httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
httpReq.headers().put(HttpHeaders.Names.COOKIE, "XYZ=value");
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
JDiscCookieWrapper[] wrappers = request.getWrappedCookies();
Assert.assertEquals(wrappers.length, 1);
Assert.assertEquals(wrappers[0].getName(), "XYZ");
Assert.assertEquals(wrappers[0].getValue(), "value");
}
use of com.yahoo.jdisc.http.HttpRequest in project vespa by vespa-engine.
the class DiscFilterRequestTest method testIsMultipart.
@Test
public void testIsMultipart() {
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");
DiscFilterRequest request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(true, DiscFilterRequest.isMultipart(request));
httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
httpReq.headers().add(HttpHeaders.Names.CONTENT_TYPE, "text/html;charset=UTF-8");
request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(DiscFilterRequest.isMultipart(request), false);
Assert.assertEquals(DiscFilterRequest.isMultipart(null), false);
httpReq = newRequest(uri, HttpRequest.Method.GET, HttpRequest.Version.HTTP_1_1);
request = new JdiscFilterRequest(httpReq);
Assert.assertEquals(DiscFilterRequest.isMultipart(request), false);
}
Aggregations