Search in sources :

Example 6 with HeaderFields

use of com.yahoo.jdisc.HeaderFields in project vespa by vespa-engine.

the class AccessControlRequestFilterTest method any_options_request_yields_access_control_headers_in_response.

@Test
public void any_options_request_yields_access_control_headers_in_response() {
    HeaderFields headers = doFilterRequest(newRequestFilter(), "http://any.origin");
    ACCESS_CONTROL_HEADERS.keySet().forEach(header -> assertFalse("Empty header: " + header, headers.getFirst(header).isEmpty()));
}
Also used : HeaderFields(com.yahoo.jdisc.HeaderFields) Test(org.junit.Test)

Example 7 with HeaderFields

use of com.yahoo.jdisc.HeaderFields 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");
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) HeaderFields(com.yahoo.jdisc.HeaderFields) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

HeaderFields (com.yahoo.jdisc.HeaderFields)7 Test (org.junit.Test)4 Test (org.testng.annotations.Test)3 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpRequest (com.yahoo.jdisc.http.HttpRequest)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1