- (FMWebDAVRequest*) createDirectory {
if (!_endSelector) {
_endSelector = @selector(requestDidCreateDirectory:);
}
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:_url];
[req setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[req setTimeoutInterval:60 * 5];
[req setHTTPMethod:@"MKCOL"];
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"skipMKCOLContentType"]) {
[req setValue:@"applicatio开发者_JAVA百科n/xml" forHTTPHeaderField:@"Content-Type"];
}
[self sendRequest:req];
return self;
This code i use for iPhone, i write WebDav client for both platforms But i don't know how to implement MKCOL for android, that what i do MKCOL it's WebDav method to create path, any ideas ?
HttpPut request = new HttpPut();
request.addHeader("", "MKCOL /test879797 HTTP/1.1");
request.addHeader("Host","myserver:port");
request.addHeader("Authorization","Basic YWRtaW46MTIzNDU2");
Use the following code:
public class HttpMkCol extends HttpEntityEnclosingRequestBase
{
public static final String METHOD_NAME = "MKCOL";
public HttpMkCol(String url)
{
this(URI.create(url));
}
public HttpMkCol(URI url)
{
this.setURI(url);
}
@Override
public String getMethod()
{
return METHOD_NAME;
}
}
The original source: https://github.com/lookfirst/sardine HttpMkCol.java
HttpPut request = new HttpPut();
MKCOL
is not PUT
.
Apache HttpClient does not directly support WebDAV. You are welcome to experiment with creating your own custom subclass of org.apache.http.message.AbstractHttpMessage
to implement the MKCOL
verb.
Or, you can see if somebody else created WebDAV extensions to Apache HttpClient.
Or, you can find another WebDAV client library for Java and see if it runs on Android.
精彩评论