Package org.apache.http

Examples of org.apache.http.HttpRequest.addHeader()


        final String authority = target.getHostName()+":"+target.getPort();

        HttpRequest req = new BasicHttpRequest
            ("CONNECT", authority, HttpVersion.HTTP_1_1);

        req.addHeader("Host", authority);

        return req;
    }

View Full Code Here


    private final static HttpRequest createRequest(HttpHost target) {

        HttpRequest req = new BasicHttpRequest
            ("OPTIONS", "*", HttpVersion.HTTP_1_1);

        req.addHeader("Host", target.getHostName());

        return req;
    }


View Full Code Here

        request.removeHeaders("Connection");
        request.addHeader("X-Unknown-Header", "some-value");

        HttpRequest downgraded = new BasicHttpRequest("GET", "/foo", HTTP_1_1);
        downgraded.removeHeaders("Connection");
        downgraded.addHeader("X-Unknown-Header", "some-value");

        RequestWrapper downgradedWrapper = new RequestWrapper(downgraded);

        EasyMock.expect(
                mockBackend.execute(EasyMock.isA(HttpHost.class), eqRequest(downgradedWrapper),
View Full Code Here

        resp1.addHeader("Cache-Control", "max-age=3600");
        resp1.setHeader(eHeader, oldVal);

        // get a head that penetrates the cache
        HttpRequest req2 = new BasicHttpRequest("HEAD", "/", HTTP_1_1);
        req2.addHeader("Cache-Control", "no-cache");
        HttpResponse resp2 = make200Response();
        resp2.setEntity(null);
        resp2.setHeader(eHeader, newVal);

        // next request doesn't tolerate stale entry
View Full Code Here

        resp2.setEntity(null);
        resp2.setHeader(eHeader, newVal);

        // next request doesn't tolerate stale entry
        HttpRequest req3 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req3.addHeader("Cache-Control", "max-stale=0");
        HttpResponse resp3 = make200Response();
        resp3.setHeader(eHeader, newVal);

        EasyMock.expect(
                mockBackend.execute(EasyMock.eq(host), eqRequest(req1), (HttpContext) EasyMock
View Full Code Here

        originResponse.addHeader("Cache-Control", "max-age=3600");
        originResponse.addHeader("ETag", "\"etag1\"");

        HttpRequest req2 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req2.addHeader("Range", "bytes=0-50");

        backendExpectsAnyRequest().andReturn(originResponse).times(1, 2);

        replayMocks();
View Full Code Here

        originResponse.addHeader("Cache-Control", "max-age=3600");
        originResponse.addHeader("Content-Location", "http://foo.example.com/other/url");

        HttpRequest req2 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req2.addHeader("Range", "bytes=0-50");

        backendExpectsAnyRequest().andReturn(originResponse).times(1, 2);

        replayMocks();
View Full Code Here

    @Test
    public void test206ResponseIncludesVariantHeadersIfValueMightDiffer() throws Exception {

        HttpRequest req1 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req1.addHeader("Accept-Encoding", "gzip");

        Date now = new Date();
        Date inOneHour = new Date(now.getTime() + 3600 * 1000L);
        originResponse.addHeader("Cache-Control", "max-age=3600");
        originResponse.addHeader("Expires", DateUtils.formatDate(inOneHour));
View Full Code Here

        originResponse.addHeader("Cache-Control", "max-age=3600");
        originResponse.addHeader("Expires", DateUtils.formatDate(inOneHour));
        originResponse.addHeader("Vary", "Accept-Encoding");

        HttpRequest req2 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req2.addHeader("Cache-Control", "no-cache");
        req2.addHeader("Accept-Encoding", "gzip");
        Date nextSecond = new Date(now.getTime() + 1000L);
        Date inTwoHoursPlusASec = new Date(now.getTime() + 2 * 3600 * 1000L + 1000L);

        HttpResponse originResponse2 = make200Response();
View Full Code Here

        originResponse.addHeader("Expires", DateUtils.formatDate(inOneHour));
        originResponse.addHeader("Vary", "Accept-Encoding");

        HttpRequest req2 = new BasicHttpRequest("GET", "/", HTTP_1_1);
        req2.addHeader("Cache-Control", "no-cache");
        req2.addHeader("Accept-Encoding", "gzip");
        Date nextSecond = new Date(now.getTime() + 1000L);
        Date inTwoHoursPlusASec = new Date(now.getTime() + 2 * 3600 * 1000L + 1000L);

        HttpResponse originResponse2 = make200Response();
        originResponse2.setHeader("Date", DateUtils.formatDate(nextSecond));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.