本文整理汇总了Java中org.apache.commons.httpclient.HttpURL.getEscapedPath方法的典型用法代码示例。如果您正苦于以下问题:Java HttpURL.getEscapedPath方法的具体用法?Java HttpURL.getEscapedPath怎么用?Java HttpURL.getEscapedPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.HttpURL
的用法示例。
在下文中一共展示了HttpURL.getEscapedPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportMethod
import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
/**
* Execute the REPORT method.
*/
public Enumeration reportMethod(HttpURL httpURL, int depth)
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
ReportMethod method = new ReportMethod(httpURL.getEscapedPath(),
depth);
method.setDebug(debug);
method.setFollowRedirects(this.followRedirects);
generateTransactionHeader(method);
client.executeMethod(method);
Vector results = new Vector();
Enumeration responses = method.getResponses();
while (responses.hasMoreElements()) {
ResponseEntity response = (ResponseEntity) responses.nextElement();
String href = response.getHref();
String sResult = href;
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
Enumeration responseProperties = method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
Property property = (Property) responseProperties.nextElement();
sResult += "\n" + property.getName() + ":\t" +
DOMUtils.getTextValue(property.getElement());
}
results.addElement(sResult);
}
return results.elements();
}
示例2: optionsMethod
import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
/**
* Execute OPTIONS method for the given http URL.
*
* @param httpURL the http URL.
* @return the allowed methods and capabilities.
* @exception HttpException
* @exception IOException
*/
public Enumeration optionsMethod(HttpURL httpURL)
throws HttpException, IOException {
HttpClient client = getSessionInstance(httpURL, true);
OptionsMethod method = new OptionsMethod(httpURL.getEscapedPath());
method.setDebug(debug);
method.setFollowRedirects(this.followRedirects);
generateTransactionHeader(method);
client.executeMethod(method);
Vector options = new Vector();
int statusCode = method.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
// check if the specific method is possbile
Enumeration allowedMethods = method.getAllowedMethods();
while (allowedMethods.hasMoreElements()) {
options.addElement(allowedMethods.nextElement());
}
// check WebDAV capabilities.
Enumeration davCapabilities = method.getDavCapabilities();
while (davCapabilities.hasMoreElements()) {
options.addElement(davCapabilities.nextElement());
}
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
ResponseEntity response =
(ResponseEntity) responses.nextElement();
Enumeration workspaces = response.getWorkspaces();
String sResult="";
while (workspaces.hasMoreElements()){
sResult += workspaces.nextElement().toString();
}
Enumeration histories = response.getHistories();
while (histories.hasMoreElements()){
sResult += histories.nextElement().toString();
}
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
options.addElement(sResult);
}
}
return options.elements();
}