Skip to content

Commit 010ffc7

Browse files
jessegeensdiocas
authored andcommitted
When returning a 206 on a GET, we set Acess-Control-Expose-Headers to expose the headers necessary for multipart range requests
1 parent b3aacc0 commit 010ffc7

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: add Acess-Control-Expose-Headers for Range requests
2+
3+
We add the necessary headers for multipart range requests to Acess-Control-Expose-Headers to expose these, so that clients can read them
4+
5+
https://github.com/cs3org/reva/pull/5403

internal/http/interceptors/cors/cors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,16 @@ func New(m map[string]interface{}) (global.Middleware, int, error) {
104104
"Upload-Checksum",
105105
"Upload-Offset",
106106
"X-HTTP-Method-Override",
107+
"Range",
107108
}
108109
}
109110

110111
if len(conf.ExposedHeaders) == 0 {
111112
conf.ExposedHeaders = []string{
112113
"Location",
114+
"Content-Range",
115+
"Content-Length",
116+
"Accept-Ranges",
113117
}
114118
}
115119

internal/http/services/owncloud/ocdav/ocdav.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func applyLayout(ctx context.Context, ns string, useLoggedInUserNS bool, request
335335
func addAccessHeaders(w http.ResponseWriter, r *http.Request) {
336336
headers := w.Header()
337337
// the webdav api is accessible from anywhere
338-
headers.Set("Access-Control-Allow-Origin", "*")
338+
headers.Set(HeaderAccessControlAllowOrigin, "*")
339339
// all resources served via the DAV endpoint should have the strictest possible as default
340340
headers.Set("Content-Security-Policy", "default-src 'none';")
341341
// disable sniffing the content type for IE

internal/http/services/owncloud/ocdav/webdav.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const (
4242
HeaderAcceptRanges = "Accept-Ranges"
4343
HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers"
4444
HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers"
45+
HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin"
4546
HeaderContentDisposistion = "Content-Disposition"
4647
HeaderContentLength = "Content-Length"
4748
HeaderContentRange = "Content-Range"

0 commit comments

Comments
 (0)