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

最も参考になるコメント

私はこの問題に遭遇しました。 https://github.com/golang/net/blob/master/webdav/webdav.go#L557でエラーが発生したときにnilを返すだけで、ローカルで修正しました

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仕様では、次のように言われています

allpropとpropnameの場合、プリンシパルに
特定のプロパティが存在するかどうかを知る権利、次にプロパティ
応答から黙って除外する必要があります。

これが私たちのユースケースに当てはまるかどうかはわかりません

全てのコメント3件

私はこの問題に遭遇しました。 https://github.com/golang/net/blob/master/webdav/webdav.go#L557でエラーが発生したときにnilを返すだけで、ローカルで修正しました

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仕様では、次のように言われています

allpropとpropnameの場合、プリンシパルに
特定のプロパティが存在するかどうかを知る権利、次にプロパティ
応答から黙って除外する必要があります。

これが私たちのユースケースに当てはまるかどうかはわかりません

壊れたリンクにアクセスする場合は4XXステータスコードを返す必要があると思います。具体的には、権限外のターゲットにリンクされたリンクの場合は403 Forbidden 、リンクされたリンクの場合は404 Not Foundです。存在しないターゲットに。

現在、エラーが返されたことにより、 FileSystem.OpenFileまたはFile.Statに転送http.StatusInternalServerError golang.org/x/net/webdav.(*Handlerから余計response.WriteHeaderコール):と原因」のhttp .ServeHTTP(webdav.go:74) "

変更https://golang.org/cl/249797はこの問題に言及しています: webdav: ignore os.PathError in PROPFIND

このページは役に立ちましたか?
0 / 5 - 0 評価