Example usage for java.net URL getAuthority

List of usage examples for java.net URL getAuthority

Introduction

In this page you can find the example usage for java.net URL getAuthority.

Prototype

public String getAuthority() 

Source Link

Document

Gets the authority part of this URL .

Usage

From source file:org.artifactory.repo.service.RepositoryServiceImpl.java

private String adjustRefererValue(Map<String, String> headersMap, String headerVal) {
    //Append the artifactory uagent to the referer
    if (headerVal == null) {
        //Fallback to host
        headerVal = headersMap.get("HOST");
        if (headerVal == null) {
            //Fallback to unknown
            headerVal = "UNKNOWN";
        }//www . j  av a 2 s  . co  m
    }
    if (!headerVal.startsWith("http")) {
        headerVal = "http://" + headerVal;
    }
    try {
        URL uri = new URL(headerVal);
        //Only use the uri up to the path part
        headerVal = uri.getProtocol() + "://" + uri.getAuthority();
    } catch (MalformedURLException e) {
        //Nothing
    }
    headerVal += "/" + HttpUtils.getArtifactoryUserAgent();
    return headerVal;
}