Go: x/net/webdav:在断开的链接上失败

创建于 2016-06-27  ·  3评论  ·  资料来源: golang/go

尝试列出包含断开链接的目录时,出现非信息性错误:

$ cadaver webdav://localhost:5555/api/v1/content                                                                                                                                         
dav:/api/v1/content/> ls etc
Listing collection `/api/v1/content/etc/': failed:
XML parse error at line 1: junk after document element

这是我从 webdav 服务器得到的:

2016/06/27 14:52:42 http: multiple response.WriteHeader calls

该错误来自 file.go [1],它在损坏的链接文件上调用 stat,但我认为它可能应该在 webdav.go walkFn [2] 中处理。

我不确定自己应该打印/返回什么,但我希望获得完整的目录列表(即我认为 webdav 不应该对此感到迷恋)这个链接以某种方式标记为损坏。

[1] https://github.com/golang/net/blob/master/webdav/file.go#L779
[2] https://github.com/golang/net/blob/master/webdav/webdav.go#L527

/cc @simon3z

最有用的评论

我只是遇到这个问题。 我在这里得到错误时只返回 nil 在本地修复它https://github.com/golang/net/blob/master/webdav/webdav.go#L557。

我用 Apache 实现测试了相同的用例,在符号链接损坏的情况下,它被默默地丢弃。

我不知道这是否是一个足够好的解决方案,但今天的行为也是不正确的。
这是错误响应的wireshark跟踪

Host: 10.21.59.204
Depth: 1
Content-Type: application/xml
Apply-To-Redirect-Ref: T
Accept-Encoding: gzip, deflate
User-Agent: gvfs/1.28.2
Accept-Language: en-us, en;q=0.9
Connection: Keep-Alive
Content-Length: 235

<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
  <D:prop>
<D:creationdate/>
<D:displayname/>
<D:getcontentlength/>
<D:getcontenttype/>
<D:getetag/>
<D:getlastmodified/>
<D:resourcetype/>
  </D:prop>
 </D:propfind>HTTP/1.1 207 status code 207
Content-Type: text/xml; charset=utf-8
Date: Wed, 15 Mar 2017 09:00:40 GMT
Content-Length: 610

<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:"><D:response><D:href>/dav</D:href><D:propstat><D:prop><D:displayname></D:displayname><D:getlastmodified>Wed, 15 Mar 2017 08:59:55 GMT</D:getlastmodified><D:resourcetype><D:collection xmlns:D="DAV:"/></D:resourcetype></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat><D:propstat><D:prop><D:creationdate></D:creationdate><D:getcontentlength></D:getcontentlength><D:getcontenttype></D:getcontenttype><D:getetag></D:getetag></D:prop><D:status>HTTP/1.1 404 Not Found</D:status></D:propstat></D:response></D:multistatus>Internal Server Error

在 Webdav Spec 中,据说

在 allprop 和 propname 的情况下,如果主体没有
知道特定财产是否存在的权利
应该默默地从响应中排除。

我不知道这是否适用于我们的用例

所有3条评论

我只是遇到这个问题。 我在这里得到错误时只返回 nil 在本地修复它https://github.com/golang/net/blob/master/webdav/webdav.go#L557。

我用 Apache 实现测试了相同的用例,在符号链接损坏的情况下,它被默默地丢弃。

我不知道这是否是一个足够好的解决方案,但今天的行为也是不正确的。
这是错误响应的wireshark跟踪

Host: 10.21.59.204
Depth: 1
Content-Type: application/xml
Apply-To-Redirect-Ref: T
Accept-Encoding: gzip, deflate
User-Agent: gvfs/1.28.2
Accept-Language: en-us, en;q=0.9
Connection: Keep-Alive
Content-Length: 235

<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
  <D:prop>
<D:creationdate/>
<D:displayname/>
<D:getcontentlength/>
<D:getcontenttype/>
<D:getetag/>
<D:getlastmodified/>
<D:resourcetype/>
  </D:prop>
 </D:propfind>HTTP/1.1 207 status code 207
Content-Type: text/xml; charset=utf-8
Date: Wed, 15 Mar 2017 09:00:40 GMT
Content-Length: 610

<?xml version="1.0" encoding="UTF-8"?><D:multistatus xmlns:D="DAV:"><D:response><D:href>/dav</D:href><D:propstat><D:prop><D:displayname></D:displayname><D:getlastmodified>Wed, 15 Mar 2017 08:59:55 GMT</D:getlastmodified><D:resourcetype><D:collection xmlns:D="DAV:"/></D:resourcetype></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat><D:propstat><D:prop><D:creationdate></D:creationdate><D:getcontentlength></D:getcontentlength><D:getcontenttype></D:getcontenttype><D:getetag></D:getetag></D:prop><D:status>HTTP/1.1 404 Not Found</D:status></D:propstat></D:response></D:multistatus>Internal Server Error

在 Webdav Spec 中,据说

在 allprop 和 propname 的情况下,如果主体没有
知道特定财产是否存在的权利
应该默默地从响应中排除。

我不知道这是否适用于我们的用例

我认为在访问损坏的链接的情况下应该返回4XX状态码,更具体地说, 403 Forbidden用于链接到超出权限目标的链接, 404 Not Found用于链接的链接到不存在的目标。

当前由FileSystem.OpenFileFile.Stat返回的错误会转移到http.StatusInternalServerError并导致“http: superfluous response.WriteHeader call from golang.org/x/net/webdav.(*Handler) .ServeHTTP (webdav.go:74)"

更改https://golang.org/cl/249797提到这个问题: webdav: ignore os.PathError in PROPFIND

此页面是否有帮助?
0 / 5 - 0 等级