Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpGet.addHeader()


    @Test
    public void testFundamentals() throws Exception {
        final HttpRoute route = new HttpRoute(target);
        final HttpGet get = new HttpGet("/test");
        get.addHeader("header", "this");
        get.addHeader("header", "that");
        final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
        final HttpClientContext context = HttpClientContext.create();

        final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
View Full Code Here


    @Test
    public void testFundamentals() throws Exception {
        final HttpRoute route = new HttpRoute(target);
        final HttpGet get = new HttpGet("/test");
        get.addHeader("header", "this");
        get.addHeader("header", "that");
        final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
        final HttpClientContext context = HttpClientContext.create();

        final CloseableHttpResponse response1 = Mockito.mock(CloseableHttpResponse.class);
        final InputStream instream1 = Mockito.spy(new ByteArrayInputStream(new byte[] {1, 2, 3}));
View Full Code Here

    @Test(expected = IOException.class)
    public void testFundamentals() throws Exception {
        final HttpRoute route = new HttpRoute(target);
        final HttpGet get = new HttpGet("/test");
        get.addHeader("header", "this");
        get.addHeader("header", "that");
        final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
        final HttpClientContext context = HttpClientContext.create();

        Mockito.when(requestExecutor.execute(
View Full Code Here

    @Test(expected = IOException.class)
    public void testFundamentals() throws Exception {
        final HttpRoute route = new HttpRoute(target);
        final HttpGet get = new HttpGet("/test");
        get.addHeader("header", "this");
        get.addHeader("header", "that");
        final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
        final HttpClientContext context = HttpClientContext.create();

        Mockito.when(requestExecutor.execute(
                Mockito.eq(route),
View Full Code Here

            /**
             * {@inheritDoc}
             */
            public void process(
                    HttpRequest request, HttpContext context) throws HttpException, IOException {
                request.addHeader("Accept-Encoding", "gzip");
            }
        });

        /* Get around Java The Language's lack of mutable closures */
        final boolean clientSawGzip[] = new boolean[1];
View Full Code Here

        HttpClient httpClient = new DefaultHttpClient(params);

        HttpGet get = new HttpGet(url.toURI());

        if (username != null) {
            get.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(username, password), "UTF-8", false));
        }

        HttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            throw new IllegalArgumentException("Failed to download the file from the URL [" + url
View Full Code Here

    }
   
    @Test
    public void testGetCustomer() throws Exception {     
        HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123");
        get.addHeader("Accept" , "application/json");
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(get);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

    }
   
    @Test
    public void testGetCustomers() throws Exception {     
        HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/");
        get.addHeader("Accept" , "application/xml");
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(get);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

    }
   
    @Test
    public void testGetSubResource() throws Exception {
        HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/orders/223/products/323");
        get.addHeader("Accept" , "application/json");
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(get);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

            StringBuffer ob = new StringBuffer();
            for (String requestOrigin : requestOrigins) {
                ob.append(requestOrigin);
                ob.append(" "); // extra trailing space won't hurt.
            }
            httpget.addHeader("Origin", ob.toString());
        }
        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String e = IOUtils.toString(entity.getContent(), "utf-8");
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.