Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Header


      int resultCode = m.getStatusCode();

      // followRedirect wont work for PUT
      if (resultCode == 302) {
        String redirectLocation;
        Header locationHeader = m.getResponseHeader("location");
        if (locationHeader != null) {
          redirectLocation = locationHeader.getValue();
          resultCode = putContent(redirectLocation, content);
        }
      }

      return resultCode;
View Full Code Here


      String charset = m.getResponseCharSet();
      if (charset == null) charset = "UTF-8";

      // check for deflate and gzip compression
      Header h = m.getResponseHeader("content-encoding");
      String encoding = (h == null) ? null : h.getValue();

      if (encoding != null && encoding.equals("deflate")) {
        byte[] body = m.getResponseAsBytes();
        InputStream is = new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(body)), 10000);
        return readContents(is, charset, maxKbytes);
View Full Code Here

      String charset = m.getResponseCharSet();
      if (charset == null) charset = "UTF-8";

      // check for deflate and gzip compression
      Header h = m.getResponseHeader("content-encoding");
      String encoding = (h == null) ? null : h.getValue();

      if (encoding != null && encoding.equals("deflate")) {
        InputStream is = new BufferedInputStream(new InflaterInputStream(m.getResponseAsStream()), 10000);
        IO.writeToFile(is, file.getPath());
View Full Code Here

      String charset = m.getResponseCharSet();
      if (charset == null) charset = "UTF-8";

      // check for deflate and gzip compression
      Header h = m.getResponseHeader("content-encoding");
      String encoding = (h == null) ? null : h.getValue();

      if (encoding != null && encoding.equals("deflate")) {
        InputStream is = new BufferedInputStream(new InflaterInputStream(m.getResponseAsStream()), 10000);
        nbytes = IO.appendToFile(is, file.getPath());
View Full Code Here

  int executeMethod(HttpMethod method)
    throws IOException
  {
    int status = httpClient.executeMethod(method);
    if (!preferredBQRFormatUsed || !preferredRDFFormatUsed || !preferredTQRFormatUsed) {
      Header header = method.getResponseHeader("Content-Type");
      if (header != null) {
        String mimetype = header.getValue();
        if (preferredBQRFormat.getDefaultMIMEType().equals(mimetype)) {
          preferredBQRFormatUsed = true;
        }
        if (preferredRDFFormat.getDefaultMIMEType().equals(mimetype)) {
          preferredRDFFormatUsed = true;
View Full Code Here

        throw new FileNotFoundException(method.getPath() + " " + method.getStatusLine());

      if (statusCode >= 300)
        throw new IOException(method.getPath() + " " + method.getStatusLine());

      Header h = method.getResponseHeader("Content-Length");
      if (h != null) {
        String s = h.getValue();
        int readLen = Integer.parseInt(s);
        if (showRequest)
          System.out.printf(" content-length = %d%n", readLen);
        if (v.getDataType() != DataType.SEQUENCE) {
          int wantSize = (int) (v.getElementSize() * (section == null ? v.getSize() : section.computeSize()));
View Full Code Here

        if (statusCode >= 300)
          throw new IOException(method.getPath() + " " + method.getStatusLine());

        int wantSize = (int) (v.getSize());
        Header h = method.getResponseHeader("Content-Length");
        if (h != null) {
          String s = h.getValue();
          int readLen = Integer.parseInt(s);
          if (readLen != wantSize)
            throw new IOException("content-length= " + readLen + " not equal expected Size= " + wantSize);
        }
View Full Code Here

  public String getResponseHeaderValue( String name )
  {
    if ( method == null )
      throw new IllegalStateException( "Request has not been made." );

    Header responseHeader = this.method.getResponseHeader( name );
    return responseHeader == null ? null : responseHeader.getValue();
  }
View Full Code Here

  {
    if ( method == null )
      throw new IllegalStateException( "Request has not been made." );

    InputStream is = method.getResponseAsStream();
    Header contentEncodingHeader = method.getResponseHeader( "Content-Encoding" );
    if ( contentEncodingHeader != null )
    {
      String contentEncoding = contentEncodingHeader.getValue();
      if ( contentEncoding != null )
      {
        if ( contentEncoding.equalsIgnoreCase( "gzip" ) )
          return new GZIPInputStream( is );
        else if ( contentEncoding.equalsIgnoreCase( "deflate" ) )
View Full Code Here

      HttpClient httpClient = new HttpClient();
      HeadMethod method = new HeadMethod(url);
      method.getParams().setIntParameter("http.socket.timeout",5000);
      int code = httpClient.executeMethod(method);
      if (code == 200) {
        Header h = method.getResponseHeader("Content-Type");
        if (h != null) {
          HeaderElement[] headElm = h.getElements();
          if(headElm != null & headElm.length > 0){
            String mimeType = headElm[0].getValue();
            if(mimeType == null){
              mimeType = headElm[0].getName();
            }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.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.