Package org.apache.commons.httpclient

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


      try {
        StringBuffer sb = new StringBuffer();
        sb.append("http://");
        sb.append(cluster.lastHost);
        sb.append(path);
        URI uri = new URI(sb.toString());
        return executeURI(method, headers, uri.toString());
      } catch (IOException e) {
        lastException = e;
      }
    } while (++i != start && i < cluster.nodes.size());
    throw lastException;
View Full Code Here


   * @throws IOException
   */
  @SuppressWarnings("deprecation")
  public int executeURI(HttpMethod method, Header[] headers, String uri)
      throws IOException {
    method.setURI(new URI(uri));
    if (headers != null) {
      for (Header header: headers) {
        method.addRequestHeader(header);
      }
    }
View Full Code Here

                    redirectLocation = locationHeader.getValue();
                }
                else {
                    throw new CloudRuntimeException("Call failed: Bad redirect from UCS Manager");
                }
                post.setURI(new URI(redirectLocation));
                result = client.executeMethod(post);
            }
            // Check for errors
            if (result != 200) {
               throw new CloudRuntimeException("Call failed: " + post.getResponseBodyAsString());
View Full Code Here

        }
    };

    @SuppressWarnings("deprecation")
    private URI getUri() throws Exception{
        return new URI(apiUrl);
    }
View Full Code Here

                file_post.addParameter("swf", selected_file);
                HttpClient client = new HttpClient();
                client.getState().setCredentials("realm", new UsernamePasswordCredentials(remote_config.getProperty("remote_user"), remote_config.getProperty("remote_pwd")));
                HostConfiguration hc = new HostConfiguration();
                file_post.setDoAuthentication(true);
                hc.setHost(new URI(remote_url));
                client.setHostConfiguration(hc);
                int status = client.executeMethod(file_post);
                file_post.releaseConnection();

                if (status == 200)
View Full Code Here

        this.pathFactory = pathFactory;
        this.qValueFactory = qValueFactory;
        this.itemInfoCacheSize = itemInfoCacheSize;

        try {
            URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
            hostConfig = new HostConfiguration();
            hostConfig.setHost(repositoryUri);

            nsCache = new NamespaceCache();
            uriResolver = new URIResolverImpl(repositoryUri, this, DomUtil.createDocument());
View Full Code Here

      if (locationHeader == null) {
            throw new XmlRpcException("Invalid redirect: Missing location header");
      }
      String location = locationHeader.getValue();

      URI redirectUri = null;
      URI currentUri = null;
      try {
          currentUri = method.getURI();
          String charset = currentUri.getProtocolCharset();
          redirectUri = new URI(location, true, charset);
          method.setURI(redirectUri);
      } catch (URIException ex) {
            throw new XmlRpcException(ex.getMessage(), ex);
      }
View Full Code Here

        this.pathFactory = pathFactory;
        this.qValueFactory = qValueFactory;
        this.itemInfoCacheSize = itemInfoCacheSize;

        try {
            URI repositoryUri = computeRepositoryUri(uri);
            hostConfig = new HostConfiguration();
            hostConfig.setHost(repositoryUri);

            nsCache = new NamespaceCache();
            uriResolver = new URIResolverImpl(repositoryUri, this, DomUtil.createDocument());
View Full Code Here

    /**
     * Compute the repository URI (while dealing with trailing / and port number
     * defaulting)
     */
    public static URI computeRepositoryUri(String uri) throws URIException {
        URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri + "/", true);
        // workaround for JCR-3228: normalize default port numbers because of
        // the weak URI matching code elsewhere (the remote server is unlikely
        // to include the port number in URIs when it's the default for the
        // protocol)
        boolean useDefaultPort = ("http".equalsIgnoreCase(repositoryUri.getScheme()) && repositoryUri.getPort() == 80)
                || (("https".equalsIgnoreCase(repositoryUri.getScheme()) && repositoryUri.getPort() == 443));
        if (useDefaultPort) {
            repositoryUri = new URI(repositoryUri.getScheme(), repositoryUri.getUserinfo(), repositoryUri.getHost(), -1,
                    repositoryUri.getPath(), repositoryUri.getQuery(), repositoryUri.getFragment());
        }

        return repositoryUri;
    }
View Full Code Here

                String location = locationHeader.getValue();
                if(LOG.isInfoEnabled())
                    LOG.info("Redirected requested to: " + location);

                URI newLocation = new URI(location.toCharArray());

                // Retrieve the RequestHeaders
                Header[] requestHeaders = methid.getRequestHeaders();

                // Recycle this method so we can use it again.
                methid.recycle();

                HostConfiguration hc = methid.getHostConfiguration();
                hc.setHost(
                    newLocation.getHost(),
                    newLocation.getPort(),
                    newLocation.getScheme()
                );

                methid.setFollowRedirects(true);

                for(int j = 0; j < requestHeaders.length; j++) {
                    if(!requestHeaders[j].getName().equals("Host"))
                        methid.addRequestHeader(requestHeaders[j]);
                }

                // Set up the new values for the method.
                methid.setPath(newLocation.getEscapedPath());
                methid.setQueryString(newLocation.getEscapedQuery());
                methid.removeRequestHeader(HttpAuthenticator.WWW_AUTH_RESP);

                // Loop around and try the method again.
                break;
            default:
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.