本文整理了Java中org.apache.commons.httpclient.URI.getPath()
方法的一些代码示例,展示了URI.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URI.getPath()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.URI
类名称:URI
方法名:getPath
[英]Get the path.
path = [ abs_path | opaque_part ]
[中]找到路。
path = [ abs_path | opaque_part ]
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: org.zaproxy/zap
/**
* Get a random path relative to the current entity. Whenever possible, use
* a suffix exist in the children according to a priority of
* staticSuffixList.
*
* @param node the node used to construct the random path
* @param uri The uri of the current entity.
* @return A random path (eg /folder1/folder2/1234567.chm) relative the
* entity.
* @throws URIException if unable to decode the path of the given URI
*/
private String getRandomPathSuffix(StructuralNode node, URI uri) throws URIException {
String resultSuffix = getChildSuffix(node, true);
String path = "";
path = (uri.getPath() == null) ? "" : uri.getPath();
path = path + (path.endsWith("/") ? "" : "/") + Long.toString(getRndPositiveLong());
path = path + resultSuffix;
return path;
}
代码示例来源:origin: org.zaproxy/zap
/**
* Return if this request header is a image request basing on the path
* suffix.
*/
@Override
public boolean isImage() {
if (getURI() == null) {
return false;
}
try {
// ZAP: prevents a NullPointerException when no path exists
final String path = getURI().getPath();
if (path != null) {
return (patternImage.matcher(path).find());
}
} catch (URIException e) {
log.error(e.getMessage(), e);
}
return false;
}
代码示例来源:origin: org.zaproxy/zap
/**
*
* @param msg
*/
@Override
public void setMessage(HttpMessage msg) {
/*
* For a URL like: http://www.example.com/aaa/bbb/ccc?ddd=eee&fff=ggg
* Add the following:
* parameter position
* aaa 1
* bbb 2
* ccc 3
*/
try {
if (msg.getRequestHeader().getURI().getPath() != null) {
String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/");
int i = 0;
for (String path : paths) {
if (path.length() > 0) {
stringParam.add(new NameValuePair(NameValuePair.TYPE_URL_PATH, path, path, i));
}
i++;
}
}
} catch (URIException e) {
// Ignore
}
}
代码示例来源:origin: org.motechproject/motech-openmrs-atomfeed
@Autowired
public OpenMrsHttpClientImpl(@Value("${openmrs.url}") String openmrsUrl) throws URIException {
Validate.notEmpty(
openmrsUrl,
"Did not find property for OpenMRS Url (openmrs.url). Cannot use the Motech Atom Feed module until this property is set");
httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
URI uri = new URI(openmrsUrl, false);
openmrsPath = uri.getPath();
httpClient.getHostConfiguration().setHost(uri);
}
代码示例来源:origin: org.zaproxy/zap
child = iter.next();
try {
if (child.getURI().getPath().endsWith(suffix)) {
return suffix;
代码示例来源: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
private File getOutputFile(HttpMessage msg) {
String filename = "";
try {
filename = msg.getRequestHeader().getURI().getPath();
int pos = filename.lastIndexOf("/");
filename = filename.substring(pos);
} catch (Exception e) {
}
JFileChooser chooser = new JFileChooser(extension.getModel().getOptionsParam().getUserDirectory());
if (filename.length() > 0) {
chooser.setSelectedFile(new File(filename));
}
File file = null;
int rc = chooser.showSaveDialog(extension.getView().getMainFrame());
if(rc == JFileChooser.APPROVE_OPTION) {
file = chooser.getSelectedFile();
if (file == null) {
return file;
}
extension.getModel().getOptionsParam().setUserDirectory(chooser.getCurrentDirectory());
return file;
}
return file;
}
代码示例来源:origin: org.zaproxy/zap
String path = msg.getRequestHeader().getURI().getPath();
String challenge = path.substring(path.indexOf(getPrefix()) + getPrefix().length() + 1);
if (challenge.charAt(challenge.length() - 1) == '/') {
代码示例来源:origin: org.zaproxy/zap
@Override
public HttpMessage handleShortcut(HttpMessage msg) throws ApiException {
try {
if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_PROXY_PAC)) {
return this.handleApiOther(msg, OTHER_PROXY_PAC, null);
} else if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_SET_PROXY)) {
JSONObject params = new JSONObject();
params.put(PARAM_PROXY_DETAILS, msg.getRequestBody().toString());
return this.handleApiOther(msg, OTHER_SET_PROXY, params);
} else if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_SCRIPT_JS)) {
return this.handleApiOther(msg, OTHER_SCRIPT_JS, null);
}
} catch (URIException e) {
logger.error(e.getMessage(), e);
throw new ApiException(ApiException.Type.INTERNAL_ERROR);
}
throw new ApiException (ApiException.Type.URL_NOT_FOUND, msg.getRequestHeader().getURI().toString());
}
代码示例来源:origin: org.zaproxy/zap
path = message.getRequestHeader().getURI().getPath();
} catch (URIException e) {
} finally {
代码示例来源:origin: org.zaproxy/zap
try {
URI uri = msg.getRequestHeader().getURI();
String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/");
代码示例来源:origin: org.zaproxy/zap
try {
String url = msg.getRequestHeader().getURI().toString();
String path = msg.getRequestHeader().getURI().getPath();
LOGGER.debug("Callback received for URL : " + url + " path : "
+ path + " from "
代码示例来源:origin: org.zaproxy/zap
StringBuilder sb = new StringBuilder();
String nodeName;
String uriPath = baseRef.getURI().getPath();
if (uriPath == null) {
uriPath = "";
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: org.zaproxy/zap
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
@Override
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Sets the URI for this method.
*
* @param uri URI to be set
*
* @throws URIException if a URI cannot be set
*
* @since 3.0
*/
public void setURI(URI uri) throws URIException {
// only set the host if specified by the URI
if (uri.isAbsoluteURI()) {
this.httphost = new HttpHost(uri);
}
// set the path, defaulting to root
setPath(
uri.getPath() == null
? "/"
: uri.getEscapedPath()
);
setQueryString(uri.getEscapedQuery());
}
代码示例来源:origin: smartrics/RestFixture
@SuppressWarnings("deprecation")
public void setURI(org.apache.commons.httpclient.HttpMethodBase m, URI uri)
throws URIException {
HostConfiguration conf = m.getHostConfiguration();
if (uri.isAbsoluteURI()) {
conf.setHost(new HttpHost(uri));
m.setHostConfiguration(conf);
}
m.setPath(uri.getPath() != null ? uri.getEscapedPath() : "/");
m.setQueryString(uri.getQuery());
}
内容来源于网络,如有侵权,请联系作者删除!