protected String getUrlForPath(final String path) {
        if (path.startsWith("http://") || (path.startsWith("https://"))) {
            return path;
        } else if (getHostname().startsWith("http://")
                || (getHostname().startsWith("https://"))) {
            return getHostname() + path;
        } else {
            return "http://" + getHostname() + path;
        }
    }