Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check status codes #1297

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/ocdav-check-status-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: check the err and the response status code

The publicfile handler needs to check the response status code to return proper not pound and permission errors in the webdav api.

https://github.com/cs3org/reva/pull/1297
27 changes: 27 additions & 0 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http"
"path"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/router"
Expand Down Expand Up @@ -106,6 +107,19 @@ func (s *svc) adjustResourcePathInURL(w http.ResponseWriter, r *http.Request) bo
w.WriteHeader(http.StatusNotFound)
return false
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return false
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return false
default:
w.WriteHeader(http.StatusInternalServerError)
return false
}
}
if path.Base(r.URL.Path) != path.Base(pathRes.Path) {
w.WriteHeader(http.StatusNotFound)
return false
Expand Down Expand Up @@ -165,6 +179,19 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
w.WriteHeader(http.StatusNotFound)
return
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return
default:
w.WriteHeader(http.StatusInternalServerError)
return
}
}

infos := []*provider.ResourceInfo{}

Expand Down