本文整理了Java中org.apache.commons.httpclient.URI.setQuery()
方法的一些代码示例,展示了URI.setQuery()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URI.setQuery()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.URI
类名称:URI
方法名:setQuery
[英]Set the query.
When a query string is not misunderstood the reserved special characters ("&", "=", "+", ",", and "$") within a query component, it is recommended to use in encoding the whole query with this method.
The additional APIs for the special purpose using by the reserved special characters used in each protocol are implemented in each protocol classes inherited from URI
. So refer to the same-named APIs implemented in each specific protocol instance.
[中]设置查询。
如果查询字符串没有被误解为查询组件中的保留特殊字符(&“、“=”、“+”、“、”和“$”),建议使用此方法对整个查询进行编码。
每个协议中使用的保留特殊字符用于特殊目的的附加API在继承自URI
的每个协议类中实现。因此,请参考在每个特定协议实例中实现的相同命名API。
代码示例来源:origin: commons-httpclient/commons-httpclient
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.zaproxy/zap
private String getPathRegex(URI uri) throws URIException {
URI newUri;
// ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient
try {
newUri = (URI) uri.clone();
} catch (CloneNotSupportedException e) {
throw new URIException(e.getMessage());
}
String query = newUri.getQuery();
StringBuilder sb = new StringBuilder(100);
// case should be sensitive
//sb.append("(?i)");
newUri.setQuery(null);
sb.append(newUri.toString().replaceAll("\\.", "\\."));
if (query != null) {
String queryPattern = "(\\?" + query + ")?";
sb.append(queryPattern);
}
return sb.toString();
}
代码示例来源:origin: org.zaproxy/zap
@Override
public String setParameter(HttpMessage msg, NameValuePair originalPair, String param, String value) {
// TODO: Implement correctly escaped / non-escaped params
OperationParameter opParam = mapParameters.get(param);
if (opParam != null) {
String newfilter = opParam.getModifiedFilter(value);
String modifiedQuery = beforeFilterExpression + newfilter + afterFilterExpression;
try {
msg.getRequestHeader().getURI().setQuery(modifiedQuery);
} catch (URIException | NullPointerException e) {
log.error("Exception with the modified query " + modifiedQuery, e);
}
return newfilter;
}
return null;
}
代码示例来源:origin: org.zaproxy/zap
mUri.setQuery("");
mUri.setQuery("");
mUri.setQuery(query);
代码示例来源:origin: org.zaproxy/zap
public synchronized void add(URI uri, String key, Object value) {
// ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient
try {
uri = (URI) uri.clone();
} catch (CloneNotSupportedException e1) {
return;
}
// ZAP: Removed variable (TreeMap map).
try {
uri.setQuery(null);
} catch (URIException e) {
// ZAP: Added logging.
logger.error(e.getMessage(), e);
return;
}
// ZAP: Moved to after the try catch block.
String uriKey = uri.toString();
// ZAP: Added the type arguments.
TreeMap<String, Object> map = mapURI.get(uriKey);
if (map == null) {
// ZAP: Added the type argument.
map = new TreeMap<>();
mapURI.put(uriKey, map);
} // ZAP: Removed else branch.
add(map, key, value);
}
代码示例来源:origin: mguessan/davmail
protected String getScriptBasedFormURL(HttpMethod initmethod, String pathQuery) throws URIException {
URI initmethodURI = initmethod.getURI();
int queryIndex = pathQuery.indexOf('?');
if (queryIndex >= 0) {
if (queryIndex > 0) {
// update path
String newPath = pathQuery.substring(0, queryIndex);
if (newPath.startsWith("/")) {
// absolute path
initmethodURI.setPath(newPath);
} else {
String currentPath = initmethodURI.getPath();
int folderIndex = currentPath.lastIndexOf('/');
if (folderIndex >= 0) {
// replace relative path
initmethodURI.setPath(currentPath.substring(0, folderIndex + 1) + newPath);
} else {
// should not happen
initmethodURI.setPath('/' + newPath);
}
}
}
initmethodURI.setQuery(pathQuery.substring(queryIndex + 1));
}
return initmethodURI.getURI();
}
代码示例来源:origin: org.zaproxy/zap
uri.setQuery(sb.toString());
uri.setQuery(null);
hrh.setURI(uri);
代码示例来源:origin: org.zaproxy/zap
public synchronized Vector<Object> getList(URI uri, String key) {
// ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient
try {
uri = (URI) uri.clone();
} catch (CloneNotSupportedException e1) {
return null;
}
// ZAP: Removed variable (TreeMap map).
try {
uri.setQuery(null);
} catch (URIException e) {
// ZAP: Added logging.
logger.error(e.getMessage(), e);
return null;
}
// ZAP: Moved to after the try catch block.
String uriKey = uri.toString();
// ZAP: Added the type argument and removed the instanceof.
TreeMap<String, Object> map = mapURI.get(uriKey);
if (map == null) {
return null;
} // ZAP: Removed else branch.
return getList(map, key);
}
代码示例来源:origin: mguessan/davmail
protected String getAbsoluteUri(HttpMethod method, String path) throws URIException {
URI uri = method.getURI();
if (path != null) {
// reset query string
uri.setQuery(null);
if (path.startsWith("/")) {
// path is absolute, replace method path
uri.setPath(path);
} else if (path.startsWith("http://") || path.startsWith("https://")) {
return path;
} else {
// relative path, build new path
String currentPath = method.getPath();
int end = currentPath.lastIndexOf('/');
if (end >= 0) {
uri.setPath(currentPath.substring(0, end + 1) + path);
} else {
throw new URIException(uri.getURI());
}
}
}
return uri.getURI();
}
代码示例来源:origin: org.zaproxy/zap
uri.setQuery(sb.toString());
uri.setQuery(null);
hrh.setURI(uri);
代码示例来源:origin: org.zaproxy/zap
@Override
public void onHttpRequestSend(HttpMessage msg) {
HttpRequestHeader header = msg.getRequestHeader();
if (header != null ) {
String cookie = header.getHeader("Cookie");
synchronized (cookieList){
if (cookie != null && cookieList.indexOf(cookie)==-1){
try {
// ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient
URI uri;
try {
uri = (URI) header.getURI().clone();
} catch (CloneNotSupportedException e) {
throw new URIException(e.getMessage());
}
uri.setQuery(null);
String sUri = uri.toString();
cookieList.add(cookie);
getView().getOutputPanel().append(sUri + DELIM + cookie + "\n");
} catch (URIException e) {
// ZAP: Print stack trace to Output tab
getView().getOutputPanel().append(e);
}
}
}
}
}
代码示例来源:origin: org.zaproxy/zap
String query = newURI.getQuery();
if (query != null) {
newURI.setQuery(null);
firstline = newURI.toString();
代码示例来源:origin: org.zaproxy/zap
String query = httpMessage.getRequestBody().toString();
if (query != null) {
newURI.setQuery(null);
firstline = newURI.toString();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.apache.commons/httpclient
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.zaproxy/zap
try {
if(redirectUri.hasQuery()) {
redirectUri.setQuery(null);
代码示例来源:origin: org.zaproxy/zap
uri.setQuery(null);
String path = uri.getPath();
path = path.replaceAll("/[^/]*$", "");
代码示例来源:origin: org.zaproxy/zap
URI baseUri = (URI) baseMsg.getRequestHeader().getURI().clone();
baseUri.setQuery(null);
内容来源于网络,如有侵权,请联系作者删除!