Package org.apache.http

Examples of org.apache.http.HttpResponse.headerIterator()


          HttpContext localContext = new BasicHttpContext();
          HttpResponse response = client.execute(meth, localContext);
          callback.onSuccess(response.toString());

          // headers response
          HeaderIterator it = response.headerIterator();
          while (it.hasNext()) {
            Header header = it.nextHeader();
            responseHeaders
                .put(header.getName(), header.getValue());
          }
View Full Code Here


            //Executing
            HttpResponse httpResponse = client.execute(httpMethod);

            //parsing responseHeaders
          
            HeaderIterator it = httpResponse.headerIterator();
            while (it.hasNext()){
              Header header = it.nextHeader();
              responseHeaders.put(header.getName(), header.getValue());
            }
           
View Full Code Here

            // check if Jenkins is reachable and in fact a jenkins server
           
            HttpClient httpclient = new DefaultHttpClient();
            HttpHead head = new HttpHead(serverUri);
            HttpResponse response = httpclient.execute(head);
            HeaderIterator it = response.headerIterator(JENKINS_HEADER);
            while (it.hasNext()) {
                jenkins_version = ((BufferedHeader)it.next()).getValue();
                LOG.debug("Jenkins Version identified: "+jenkins_version);
            }
        } catch (Exception ex) {
View Full Code Here

        final DefaultConnectionKeepAliveStrategy strategy =
                (DefaultConnectionKeepAliveStrategy) spyHttpClientBuilderField("keepAliveStrategy", apacheBuilder);
        final HttpContext context = mock(HttpContext.class);
        final HttpResponse response = mock(HttpResponse.class);
        when(response.headerIterator(HTTP.CONN_KEEP_ALIVE)).thenReturn(mock(HeaderIterator.class));

        assertThat(strategy.getKeepAliveDuration(response, context)).isEqualTo(1000);
    }

    @Test
View Full Code Here

        final HttpResponse response = mock(HttpResponse.class);
        final HeaderIterator iterator = new BasicListHeaderIterator(
                ImmutableList.<Header>of(new BasicHeader(HttpHeaders.CONNECTION, "timeout=50")),
                HttpHeaders.CONNECTION
        );
        when(response.headerIterator(HTTP.CONN_KEEP_ALIVE)).thenReturn(iterator);

        assertThat(strategy.getKeepAliveDuration(response, context)).isEqualTo(50000);
    }

    @Test
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.