mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
s3: handle response-content-encoding
fix https://github.com/chrislusf/seaweedfs/issues/1487
This commit is contained in:
parent
7726965a47
commit
dbf5327b98
|
@ -210,6 +210,15 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
|
|||
|
||||
}
|
||||
|
||||
var passThroughHeaders = []string{
|
||||
"response-cache-control",
|
||||
"response-content-disposition",
|
||||
"response-content-encoding",
|
||||
"response-content-language",
|
||||
"response-content-type",
|
||||
"response-expires",
|
||||
}
|
||||
|
||||
func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, destUrl string, responseFn func(proxyResponse *http.Response, w http.ResponseWriter)) {
|
||||
|
||||
glog.V(2).Infof("s3 proxying %s to %s", r.Method, destUrl)
|
||||
|
@ -226,6 +235,19 @@ func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, des
|
|||
proxyReq.Header.Set("X-Forwarded-For", r.RemoteAddr)
|
||||
|
||||
for header, values := range r.Header {
|
||||
// handle s3 related headers
|
||||
passed := false
|
||||
for _, h := range passThroughHeaders {
|
||||
if strings.ToLower(header) == h && len(values) > 0 {
|
||||
proxyReq.Header.Add(header[len("response-"):], values[0])
|
||||
passed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if passed {
|
||||
continue
|
||||
}
|
||||
// handle other headers
|
||||
for _, value := range values {
|
||||
proxyReq.Header.Add(header, value)
|
||||
}
|
||||
|
@ -248,6 +270,7 @@ func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, des
|
|||
responseFn(resp, w)
|
||||
|
||||
}
|
||||
|
||||
func passThroughResponse(proxyResponse *http.Response, w http.ResponseWriter) {
|
||||
for k, v := range proxyResponse.Header {
|
||||
w.Header()[k] = v
|
||||
|
|
Loading…
Reference in a new issue