List of usage examples for org.apache.commons.httpclient.util URIUtil encodePathQuery
public static String encodePathQuery(String unescaped, String charset) throws URIException
From source file:com.esri.gpt.control.webharvest.client.waf.WafFile.java
private String encode(String url) { url = Val.chkStr(url);//from www . j av a 2 s.com try { return URIUtil.encodePathQuery(URIUtil.decode(url, "UTF-8"), "UTF-8"); } catch (URIException ex) { return url; } }
From source file:com.zenkey.net.prowser.Request.java
/************************************************************************** * Constructs a new <code>Request</code> object for the specified URI * string, which is assumed to be URL-encoded if the <code>isEncoded</code> * argument is <code>true</code>; all other request properties receive * default values. For a list of default property values, see * {@link #Request(URI)}.//from w ww . j a v a 2s . com * <p> * If <code>isEncoded</code> is <code>false</code>, then this * constructor will URL-encode the path and query (if any). * * @param uri * The request's URI. * @param isEncoded * <code>true</code> when the supplied URI is URL-encoded; * <code>false</code> otherwise. * @throws URISyntaxException * If string could not be parsed as a URI reference. */ public Request(String uri, boolean isEncoded) throws URISyntaxException { if (!isEncoded) { String encodedUri = null; try { encodedUri = URIUtil.encodePathQuery(uri, "UTF-8"); } catch (URIException e) { // Never reached because UTF-8 is supported } this.uri = new URI(encodedUri); } else this.uri = new URI(uri); // Add parameters from the URI's query string to the request object addParameters(getQueryMap()); }
From source file:org.apache.synapse.util.xpath.URLEncodeFunction.java
private Object encode(boolean debugOn, String encoding, String value) throws FunctionCallException { if (value == null || "".equals(value)) { if (debugOn) { log.debug("Non empty string value should be provided for encoding"); }/*from ww w .ja v a 2 s. co m*/ return SynapseXPathConstants.NULL_STRING; } String encodedString; try { encodedString = URIUtil.encodePathQuery(value, encoding); } catch (URIException e) { String msg = "Unsupported charset encoding"; log.error(msg, e); throw new FunctionCallException(msg, e); } if (debugOn) { log.debug("Converted string: " + value + " with encoding: " + encoding + " to url encoded value: " + encodedString); } return encodedString; }