Example usage for org.apache.commons.httpclient URI URI

List of usage examples for org.apache.commons.httpclient URI URI

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URI URI.

Prototype

public URI(String scheme, String userinfo, String host, int port, String path, String query, String fragment)
        throws URIException 

Source Link

Document

Construct a general URI from the given components.

Usage

From source file:ai.baby.util.Parameter.java

public String toURL() {
    try {/* w w w  .ja  v  a 2s . co  m*/
        final URL url = new URL(parameterString.getObjectAsValid());
        final URI returnVal = new URI(url.getProtocol(), null, url.getHost(), 80, url.getPath(), url.getQuery(),
                null);
        return returnVal.toString();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.jivesoftware.os.jive.utils.http.client.ApacheHttpClient31BackedHttpClient.java

private void signWithOAuth(HttpMethod method) throws IOException {
    try {//from w  w w . j  av a 2  s.  c  o m
        HostConfiguration hostConfiguration = client.getHostConfiguration();

        URI uri = method.getURI();
        URI newUri = new URI((isSSLEnabled) ? "https" : "http", uri.getUserinfo(), hostConfiguration.getHost(),
                hostConfiguration.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());

        method.setURI(newUri);

        //URI checkUri = method.getURI();
        //String checkUriString = checkUri.toString();
        CommonsHttp3OAuthConsumer oAuthConsumer = new CommonsHttp3OAuthConsumer(consumerKey, consumerSecret);
        oAuthConsumer.setTokenWithSecret(consumerKey, consumerSecret);
        oAuthConsumer.sign(method);
    } catch (Exception e) {
        throw new IOException("Failed to OAuth sign HTTPRequest", e);
    }
}