/** * Construct a general URI with the given relative URI string. * * @param base the base URI * @param relative the relative URI string * @throws URIException If the new URI cannot be created. * * @deprecated Use #URI(URI, String, boolean) */ public URI(URI base, String relative) throws URIException { this(base, new URI(relative)); }
/** * Construct a general URI with the given relative URI string. * * @param base the base URI * @param relative the relative URI string * @param escaped <tt>true</tt> if URI character sequence is in escaped form. * <tt>false</tt> otherwise. * * @throws URIException If the new URI cannot be created. * * @since 3.0 */ public URI(URI base, String relative, boolean escaped) throws URIException { this(base, new URI(relative, escaped)); }
public URI getURI() throws URIException { String charset = getParams().getUriCharset(); return new URI(getPath(), true, charset); }
/** * Returns the URI of the HTTP method * * @return The URI * * @throws URIException If the URI cannot be created. * * @see org.apache.commons.httpclient.HttpMethod#getURI() */ public URI getURI() throws URIException { StringBuffer buffer = new StringBuffer(); if (this.httphost != null) { buffer.append(this.httphost.getProtocol().getScheme()); buffer.append("://"); buffer.append(this.httphost.getHostName()); int port = this.httphost.getPort(); if (port != -1 && port != this.httphost.getProtocol().getDefaultPort()) { buffer.append(":"); buffer.append(port); } } buffer.append(this.path); if (this.queryString != null) { buffer.append('?'); buffer.append(this.queryString); } String charset = getParams().getUriCharset(); return new URI(buffer.toString(), true, charset); }
/** * Constructor specifying a URI. * It is responsibility of the caller to ensure that URI elements * (path & query parameters) are properly encoded (URL safe). * * @param uri either an absolute or relative URI. The URI is expected * to be URL-encoded * * @throws IllegalArgumentException when URI is invalid * @throws IllegalStateException when protocol of the absolute URI is not recognised */ public HttpMethodBase(String uri) throws IllegalArgumentException, IllegalStateException { try { // create a URI and allow for null/empty uri values if (uri == null || uri.equals("")) { uri = "/"; } String charset = getParams().getUriCharset(); setURI(new URI(uri, true, charset)); } catch (URIException e) { throw new IllegalArgumentException("Invalid uri '" + uri + "': " + e.getMessage() ); } }
return new URI(SCHEME + segmentFileURI.toString(), /* boolean escaped */ false).toString(); } catch (InvalidControllerConfigException e) { LOGGER.error("Invalid controller config exception from instance {} for segment {}", instanceId, segmentName, e);
throw new EsHadoopInvalidRequest("URI has query portion on it: [" + uri + "]"); http.setURI(new URI(escapeUri(uri.toString(), sslEnabled), false));
hostConfig.setHost(new URI(escapeUri(host, sslEnabled), false)); } catch (IOException ex) { throw new EsHadoopTransportException("Invalid target URI " + host, ex);
throw new CloudRuntimeException("Call failed: Bad redirect from UCS Manager"); post.setURI(new URI(redirectLocation)); result = client.executeMethod(post);
org.apache.commons.httpclient.HttpMethod httpMethod = null; try { URI uri = new URI(request.getURI().toString(), false, Consts.UTF_8.name()); if (method == HttpMethod.GET) {
/** * Construct a general URI with the given relative URI string. * * @param base the base URI * @param relative the relative URI string * @throws URIException If the new URI cannot be created. * * @deprecated Use #URI(URI, String, boolean) */ public URI(URI base, String relative) throws URIException { this(base, new URI(relative)); }
/** * Construct a general URI with the given relative URI string. * * @param base the base URI * @param relative the relative URI string * @throws URIException If the new URI cannot be created. * * @deprecated Use #URI(URI, String, boolean) */ public URI(URI base, String relative) throws URIException { this(base, new URI(relative)); }
/** * Construct a general URI with the given relative URI string. * * @param base the base URI * @param relative the relative URI string * @throws URIException If the new URI cannot be created. * * @deprecated Use #URI(URI, String, boolean) */ public URI(URI base, String relative) throws URIException { this(base, new URI(relative)); }
private URI createURI(URI base, String dir, String file) throws URIException { if (!dir.startsWith("/")) { dir = "/" + dir; } if (!file.startsWith("/") && !dir.endsWith("/")) { file = "/" + file; } String path = dir + file; URI uri = new URI(base, path, true); return uri; }
public URI getCheatSheetKeyURI() throws URIException, NullPointerException { return new URI(API.getInstance().getBaseURL( API.Format.OTHER, PREFIX, API.RequestType.other, OTHER_CHEETSHEET_KEY_ORDER, false), true); }
public URI getCheatSheetActionURI() throws URIException, NullPointerException { return new URI(API.getInstance().getBaseURL( API.Format.OTHER, PREFIX, API.RequestType.other, OTHER_CHEETSHEET_ACTION_ORDER, false), true); }
protected String encodeAndFixUrl(String url) throws URIException { String originalUrl = URIUtil.encodePath(url); if (restoreHostName && originalUrl.startsWith("http")) { String targetPath = new URI(originalUrl, true).getEscapedPath(); originalUrl = getEscapedUrlFromPath(targetPath); } return originalUrl; }
protected String getEscapedUrlFromPath(String escapedPath) throws URIException { URI uri = new URI(httpClient.getHostConfiguration().getHostURL(), true); uri.setEscapedPath(escapedPath); return uri.getEscapedURI(); }
@Override public void addAuthentication(HttpMethod forMethod, HttpClient forClient) { try { forMethod.addRequestHeader("Authorization", "token " + accessToken); String url = forMethod.getURI().toString(); String separator = url.contains("?") ? "&" : "?"; url += separator + "access_token=" + getAccessToken(); forMethod.setURI(new URI(url, true)); } catch (URIException e) { throw new SourceControlException("Failed to decode/encode given URI. " + e.getMessage(), e); } }