Package org.apache.http

Examples of org.apache.http.Header


        // method.addRequestHeader( "Cache-store", "no-store" );
        // method.addRequestHeader( "Pragma", "no-cache" );
        // method.addRequestHeader( "Expires", "0" );
        // method.addRequestHeader( "Accept-Encoding", "gzip" );

        Header header = method.getFirstHeader( "Cache-control" );
        assertNull( header );

        header = method.getFirstHeader( "Cache-store" );
        assertNull( header );
View Full Code Here


                .withCredentials(username, password)
            )
            .assertStatus(302)
            .getResponse();
       
        final Header location = response.getFirstHeader(LOCATION_HEADER);
        assertNotNull("Expecting " + LOCATION_HEADER + " in response", location);
        actualPath = locationToPath(location.getValue());
        return actualPath;
    }
View Full Code Here

public class HttpCacheFilterTest {

  @Test
  public void confirmHeaderElementParameterAssumptions() {
    Header header = new BasicHeader("Cache-Control", "max-age=3600,must-revalidate");
    assertEquals("Cache-Control", header.getName());
    HeaderElement[] elements = header.getElements();
    assertEquals(2, elements.length);

    assertEquals("max-age", elements[0].getName());
    assertEquals("3600", elements[0].getValue());
    assertEquals("must-revalidate", elements[1].getName());
View Full Code Here

    else
      return (int)longLength;
  }

  protected String inspectUri(final HttpRequestBase request, final HttpResponse response) {
    Header contentLocation = Util.findHeader(response, "content-location");
    if (contentLocation != null && contentLocation.getValue() != null)
      return contentLocation.getValue();

    Header mechanizeLocation = Util.findHeader(response, Mechanize.MECHANIZE_LOCATION);
    if (mechanizeLocation!=null && mechanizeLocation.getValue()!=null)
      return mechanizeLocation.getValue();

    return request.getURI().toString();
  }
View Full Code Here

  private void setupClient(final AbstractHttpClient client) {
    this.client.addResponseInterceptor(new HttpResponseInterceptor() {
      @Override
      public void process(final HttpResponse response, final HttpContext context)
          throws HttpException, IOException {
        Header header = response.getFirstHeader("Location");
        if (header!=null)
          context.setAttribute("Location", header.getValue());
      }
    });
  }
View Full Code Here

      IOUtils.closeQuietly(in);
    }
  }

  private String getHeader(final HttpResponse response, final String name) {
    final Header header = response.getFirstHeader(name);
    return header != null ? header.getValue() : "";
  }
View Full Code Here

    }

    @Override
    public Optional<String> getSpanName() {
        Optional<String> spanName = Optional.absent();
        final Header spanNameHeader = request.getFirstHeader(BraveHttpHeaders.SpanName.getName());
        if (spanNameHeader != null) {
            spanName = Optional.fromNullable(spanNameHeader.getValue());
        }
        return spanName;
    }
View Full Code Here

        String copy = null;
        if (responseBody != null) {
            copy = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, responseBody);
        }

        Header locationHeader = httpResponse.getFirstHeader("location");
        if (locationHeader != null && (responseCode >= 300 && responseCode < 400)) {
            answer = new HttpOperationFailedException(uri, responseCode, statusText, locationHeader.getValue(), headers, copy);
        } else {
            answer = new HttpOperationFailedException(uri, responseCode, statusText, null, headers, copy);
        }

        return answer;
View Full Code Here

        InputStream is = entity.getContent();
        if (is == null) {
            return null;
        }

        Header header = httpResponse.getFirstHeader(Exchange.CONTENT_ENCODING);
        String contentEncoding = header != null ? header.getValue() : null;

        if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            is = GZIPHelper.uncompressGzip(contentEncoding, is);
        }
        // Honor the character encoding
        String contentType = null;
        header = httpRequest.getFirstHeader("content-type");
        if (header != null) {
            contentType = header.getValue();
            // find the charset and set it to the Exchange
            HttpHelper.setCharsetFromContentType(contentType, exchange);
        }
        InputStream response = doExtractResponseBodyAsStream(is, exchange);
        // if content type is a serialized java object then de-serialize it back to a Java object
View Full Code Here

            hostAddress = (String)(localContext.getAttribute(HOST_ADDRESS));
            if (hostAddress == null) {
                throw new UrlFetchException(url, "Host address not saved in context");
            }

            Header cth = response.getFirstHeader(HttpHeaderNames.CONTENT_TYPE);
            if (cth != null) {
                contentType = cth.getValue();
            }

            // Check if we should abort due to mime-type filtering. Note that this will fail if the server
            // doesn't report a mime-type, but that's how we want it as this configuration is typically
            // used when only a subset of parsers are installed/enabled, so we don't want the auto-detect
View Full Code Here

TOP

Related Classes of org.apache.http.Header

Copyright © 2018 www.massapicom. 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.