我对WebDAV有问题.我必须获取文件列表.我有这个要求:
I have a problem with WebDAV. I have to get a list of files. I have this request:
<?xml version="1.0"?> <D:searchrequest xmlns:D = "DAV:"> <D:sql> SELECT "DAV:displayname" FROM "address" WHERE "DAV:ishidden" = false AND "DAV:isfolder" = false </D:sql> </D:searchrequest>响应:
401-未经授权:由于凭据无效,访问被拒绝.
401 - Unauthorized: Access is denied due to invalid credentials.
我有用户名和密码(可以访问),但是我不知道如何将这些数据发送到XML请求中.
I have user and password (who has access), but I don't know, how I can put this data to XML request.
推荐答案WebDAV使用HTTP身份验证.
WebDAV uses an HTTP authentication.
因此,您将凭据放入HTTP标头,而不是HTTP正文中的WebDAV XML.
So you put your credentials to an HTTP header, not to the WebDAV XML in the HTTP body.
基本的HTTP身份验证的工作方式如下:
The basic HTTP authentication works like:
-
您从服务器获取WWW-Authenticate标头
您将Authorization标头包含在下一个请求中.标头的值为:
You include the Authorization header to the next request. The value of the header is:
Authorization: Basic username:password其中username:password采用Base-64编码.
where the username:password is in Base-64 encoding.
Authorization: Basic dXNlcjpwYXNzd29yZA==
有关详细信息,请参见
- 维基百科上的基本访问身份验证
- RFC 7235 :超文本传输协议(HTTP/1.1):身份验证
- Basic access authentication on Wikipedia
- RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication
更多推荐
WebDAV返回401
发布评论