Java Code Examples for org.apache.commons.httpclient.URI#isAbsoluteURI()

The following examples show how to use org.apache.commons.httpclient.URI#isAbsoluteURI() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpClient3RequestWrapper.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public String getDestinationId() {
    try {
        final URI uri = this.httpMethod.getURI();
        // if uri have schema or not found HttpConnection argument.
        if (uri.isAbsoluteURI() || this.httpConnection == null) {
            return getEndpoint(uri.getHost(), uri.getPort());
        }
        final String host = this.httpConnection.getHost();
        final int port = getPort(this.httpConnection);
        return getEndpoint(host, port);
    } catch (Exception e) {
        if (isDebug) {
            logger.debug("Failed to get destinationId. httpMethod={}", this.httpMethod, e);
        }
    }
    return "unknown";
}
 
Example 2
Source File: HttpClient3RequestWrapper.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public String getUrl() {
    try {
        final URI uri = this.httpMethod.getURI();
        // if uri have schema or not found HttpConnection argument.
        if (uri.isAbsoluteURI() || this.httpConnection == null) {
            return uri.getURI();
        }
        final String host = this.httpConnection.getHost();
        final int port = getPort(this.httpConnection);
        return getHttpUrl(host, port, uri, this.httpConnection);
    } catch (Exception e) {
        if (isDebug) {
            logger.debug("Failed to get url. httpMethod={}", this.httpMethod, e);
        }
    }
    return null;
}
 
Example 3
Source File: HttpMethodBaseExecuteMethodInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
private String getHost(HttpMethod httpMethod, HttpConnection httpConnection) {
    try {
        final URI uri = httpMethod.getURI();
        // if uri have schema
        if (uri.isAbsoluteURI()) {
            return HttpClient3RequestWrapper.getEndpoint(uri.getHost(), uri.getPort());
        }
        if (httpConnection != null) {
            final String host = httpConnection.getHost();
            final int port = HttpClient3RequestWrapper.getPort(httpConnection);
            return HttpClient3RequestWrapper.getEndpoint(host, port);
        }
    } catch (Exception e) {
        if (isDebug) {
            logger.debug("Failed to get host. httpMethod={}", httpMethod, e);
        }
    }
    return null;
}