Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.URI$LocaleToCharsetMap


  {
    ExtendedGetMethod getMethod = new ExtendedGetMethod();
    for( Header header : httpMethod.getRequestHeaders() )
      getMethod.addRequestHeader( header );

    URI uri = new URI( httpMethod.getResponseHeader( "Location" ).getValue(), true );
    getMethod.setURI( uri );
    HostConfiguration host = new HostConfiguration();
    host.setHost( uri );
    httpClient.executeMethod( host, getMethod, httpState );
    if( isRedirectResponse( getMethod ) )
View Full Code Here


      if (!this.getRequestHeader().getMethod().equalsIgnoreCase(msg.getRequestHeader().getMethod())) {
          return false;
      }
     
      // compare host, port and URI
      URI uri1 = this.getRequestHeader().getURI();
      URI uri2 = msg.getRequestHeader().getURI();

     
      try {
            if (uri1.getHost() == null || uri2.getHost() == null || !uri1.getHost().equalsIgnoreCase(uri2.getHost())) {
                return false;
            }
           
            if (uri1.getPort() != uri2.getPort()) {
                return false;
            }
           
            String pathQuery1 = uri1.getPathQuery();
            String pathQuery2 = uri2.getPathQuery();

            if (pathQuery1 == null && pathQuery2 == null) {
                return true;
            } else if (pathQuery1 != null && pathQuery2 != null) {
                return pathQuery1.equalsIgnoreCase(pathQuery2);
View Full Code Here

      if (!this.getRequestHeader().getMethod().equalsIgnoreCase(msg.getRequestHeader().getMethod())) {
          return false;
      }
     
      // compare host, port and URI
      URI uri1 = this.getRequestHeader().getURI();
      URI uri2 = msg.getRequestHeader().getURI();

     
      try {
            if (uri1.getHost() == null || uri2.getHost() == null || !uri1.getHost().equalsIgnoreCase(uri2.getHost())) {
                return false;
            }
           
            if (uri1.getPort() != uri2.getPort()) {
                return false;
            }
           
            String path1 = uri1.getPath();
            String path2 = uri2.getPath();

            if (path1 == null && path2 == null) {
                return true;
            }
           
View Full Code Here

  }
 
  private boolean queryEquals(HttpMessage msg) throws URIException {
      boolean result = false;
     
      URI uri1 = this.getRequestHeader().getURI();
      URI uri2 = msg.getRequestHeader().getURI();

      String query1 = "";
      String query2 = "";

      SortedSet set1 = null;
      SortedSet set2 = null;

        // compare the URI query part.  2 msg is consider same param set here.
        if (uri1.getQuery() != null) query1 = uri1.getQuery();
        if (uri2.getQuery() != null) query2 = uri2.getQuery();

        set1 = getParamNameSet(query1);
      set2 = getParamNameSet(query2);

      if (!set1.equals(set2)) {
View Full Code Here

            // loop 1 time only because httpclient can handle redirect itself after first GET.
            for (int i=0; i<1
            && (HttpStatusCode.isRedirection(temp.getResponseHeader().getStatusCode())
                    && temp.getResponseHeader().getStatusCode() != HttpStatusCode.NOT_MODIFIED); i++) {
                String location = temp.getResponseHeader().getHeader(HttpHeader.LOCATION);
                URI baseUri = temp.getRequestHeader().getURI();
                URI newLocation = new URI(baseUri, location, false);
                temp.getRequestHeader().setURI(newLocation);
               
                temp.getRequestHeader().setMethod(HttpRequestHeader.GET);
                temp.getRequestHeader().setContentLength(0);
                send(temp, true);
View Full Code Here

            // loop 1 time only because httpclient can handle redirect itself after first GET.
            for (int i=0; i<1
            && (HttpStatusCode.isRedirection(temp.getResponseHeader().getStatusCode())
                    && temp.getResponseHeader().getStatusCode() != HttpStatusCode.NOT_MODIFIED); i++) {
                String location = temp.getResponseHeader().getHeader(HttpHeader.LOCATION);
                URI baseUri = temp.getRequestHeader().getURI();
                URI newLocation = new URI(baseUri, location, false);
                temp.getRequestHeader().setURI(newLocation);
               
                temp.getRequestHeader().setMethod(HttpRequestHeader.GET);
                temp.getRequestHeader().setContentLength(0);
                send(temp, true, pipe, buf);
View Full Code Here

   * @throws NullPointerException
   */
  public void setURI(URI uri) throws URIException, NullPointerException {

    if (uri.getScheme() == null || uri.getScheme().equals("")) {
      mUri = new URI(HTTP + "://" + getHeader(HOST) + "/" + mUri.toString(), true);
    } else {
        mUri = uri;
    }
   
    if (uri.getScheme().equalsIgnoreCase(HTTPS)) {
View Full Code Here

      return;
    }
   
    // check if URI consistent
    if (getSecure()&& mUri.getScheme().equalsIgnoreCase(HTTP)) {
      mUri = new URI(mUri.toString().replaceFirst(HTTP, HTTPS), true);
      return;
    }

    if (!getSecure()&& mUri.getScheme().equalsIgnoreCase(HTTPS)) {
      mUri = new URI(mUri.toString().replaceFirst(HTTPS, HTTP), true);
      return;
    }


  }
View Full Code Here

        }

        mUri    = parseURI(sUri);
       
    if (mUri.getScheme() == null || mUri.getScheme().equals("")) {
      mUri = new URI(HTTP + "://" + getHeader(HOST) + mUri.toString(), true);
    }

    if (getSecure() && mUri.getScheme().equalsIgnoreCase(HTTP)) {
      mUri = new URI(mUri.toString().replaceFirst(HTTP, HTTPS), true);
    }
   
    if (mUri.getScheme().equalsIgnoreCase(HTTPS)) {
      setSecure(true);
    }
View Full Code Here

  private static final String DELIM = "<>#\"";
  private static final String UNWISE = "{}|\\^[]`";
  private static final String DELIM_UNWISE = DELIM + UNWISE;
 
  public static URI parseURI(String sUri) throws URIException {
      URI uri = null;
     
      int len = sUri.length();
      StringBuffer sb = new StringBuffer(len);
        char[] charray = new char[1];
        String s = null;

      for (int i=0; i<len; i++) {
          char ch = sUri.charAt(i);
          //String ch = sUri.substring(i, i+1);
          if (DELIM_UNWISE.indexOf(ch) >= 0) {
              // check if unwise or delim in RFC.  If so, encode it.
              charray[0] = ch;
              s = new String(charray);
              try {
                  s = URLEncoder.encode(s, "UTF8");
              } catch (UnsupportedEncodingException e1) {
              }
              sb.append(s);
          } else if (ch == '%') {

              // % is exception - no encoding to be done because some server may not handle
              // correctly when % is invalid.
              //
             
              //sb.append(ch);

              // if % followed by hex, no encode.

              try {
                String hex = sUri.substring(i+1,i+3);
                  int parsed = Integer.parseInt(hex, 16);
                  sb.append(ch);
              } catch (Exception e) {
                charray[0] = ch;
                s = new String(charray);
                try {
                    s = URLEncoder.encode(s, "UTF8");
                } catch (UnsupportedEncodingException e1) {
                }
                sb.append(s);
              }
          } else if (ch == ' ') {
              // if URLencode, '+' will be appended.
              sb.append("%20");
          } else {
              sb.append(ch);
          }
      }
      uri = new URI(sb.toString(), true);
    return uri;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.URI$LocaleToCharsetMap

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.