Package org.apache.http

Examples of org.apache.http.HttpRequestInterceptor.process()


    @Test(expected=IllegalArgumentException.class)
    public void testRequestParameterCheck() throws Exception {
        final HttpContext context = new BasicHttpContext();
        final HttpRequestInterceptor interceptor = new RequestDefaultHeaders();
        interceptor.process(null, context);
    }

    @Test
    public void testNoDefaultHeadersForConnectRequest() throws Exception {
        final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
View Full Code Here


        final List<Header> defheaders = new ArrayList<Header>();
        defheaders.add(new BasicHeader("custom", "stuff"));
        final HttpContext context = new BasicHttpContext();

        final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(defheaders);
        interceptor.process(request, context);
        final Header header1 = request.getFirstHeader("custom");
        Assert.assertNull(header1);
    }

    @Test
View Full Code Here

        final List<Header> defheaders = new ArrayList<Header>();
        defheaders.add(new BasicHeader("custom", "more stuff"));
        final HttpContext context = new BasicHttpContext();

        final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(defheaders);
        interceptor.process(request, context);
        final Header[] headers = request.getHeaders("custom");
        Assert.assertNotNull(headers);
        Assert.assertEquals(2, headers.length);
        Assert.assertEquals("stuff", headers[0].getValue());
        Assert.assertEquals("more stuff", headers[1].getValue());
View Full Code Here

            final HttpContext context)
                throws IOException, HttpException {
        if (this.requestInterceptors != null) {
            for (int i = 0; i < this.requestInterceptors.size(); i++) {
                HttpRequestInterceptor interceptor = (HttpRequestInterceptor) this.requestInterceptors.get(i);
                interceptor.process(request, context);
            }
        }
    }

    // non-Javadoc, see interface HttpResponseInterceptor (via HttpProcessor)
View Full Code Here

            final HttpContext context)
                throws IOException, HttpException {
        if (this.requestInterceptors != null) {
            for (int i = 0; i < this.requestInterceptors.size(); i++) {
                HttpRequestInterceptor interceptor = (HttpRequestInterceptor) this.requestInterceptors.get(i);
                interceptor.process(request, context);
            }
        }
    }

    protected void postprocessResponse(
View Full Code Here

            final HttpContext context)
                throws IOException, HttpException {
        if (this.requestInterceptors != null) {
            for (int i = 0; i < this.requestInterceptors.size(); i++) {
                HttpRequestInterceptor interceptor = (HttpRequestInterceptor) this.requestInterceptors.get(i);
                interceptor.process(request, context);
            }
        }
    }

    // non-Javadoc, see interface HttpResponseInterceptor (via HttpProcessor)
View Full Code Here

    public void testAcceptEncoding() throws Exception {
        HttpRequest request = new BasicHttpRequest("GET", "/");
        HttpContext context = new BasicHttpContext();

        HttpRequestInterceptor interceptor = new RequestAcceptEncoding();
        interceptor.process(request, context);
        Header header = request.getFirstHeader("Accept-Encoding");
        Assert.assertNotNull(header);
        Assert.assertEquals("gzip,deflate", header.getValue());
    }
View Full Code Here

        HttpRequest request = new BasicHttpRequest("GET", "/");
        request.addHeader("Accept-Encoding", "stuff");
        HttpContext context = new BasicHttpContext();

        HttpRequestInterceptor interceptor = new RequestAcceptEncoding();
        interceptor.process(request, context);
        Header header = request.getFirstHeader("Accept-Encoding");
        Assert.assertNotNull(header);
        Assert.assertEquals("stuff", header.getValue());
    }
View Full Code Here

            final HttpContext context)
            throws IOException, HttpException {
        for (int i = 0; i < this.requestInterceptors.size(); i++) {
            HttpRequestInterceptor interceptor =
                (HttpRequestInterceptor) this.requestInterceptors.get(i);
            interceptor.process(request, context);
        }
    }
   
    // non-Javadoc, see interface HttpResponseInterceptor (via HttpProcessor)
    public void process(
View Full Code Here

            final HttpContext context)
            throws IOException, HttpException {
        for (int i = 0; i < this.requestInterceptors.size(); i++) {
            final HttpRequestInterceptor interceptor =
                this.requestInterceptors.get(i);
            interceptor.process(request, context);
        }
    }

    public void process(
            final HttpResponse response,
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.