Code example for BasicHttpRequest

Methods: getHeaders

0
        Assert.assertEquals(0, headers2.length);
    } 
 
    @Test 
    public void testNoCookieStore() throws Exception { 
        HttpRequest request = new BasicHttpRequest("GET", "/");
 
        HttpRoute route = new HttpRoute(this.target, null, false);
 
        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);
 
        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, null);
        context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
 
        HttpRequestInterceptor interceptor = new RequestAddCookies();
        interceptor.process(request, context);
 
        Header[] headers1 = request.getHeaders(SM.COOKIE);
        Assert.assertNotNull(headers1);
        Assert.assertEquals(0, headers1.length);
        Header[] headers2 = request.getHeaders(SM.COOKIE2);
        Assert.assertNotNull(headers2);
        Assert.assertEquals(0, headers2.length);
    } 
 
    @Test 
Experience pair programming with AI  Get Codota for Java