aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/common.go10
-rw-r--r--weed/server/filer_server_handlers_read.go2
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go2
3 files changed, 11 insertions, 3 deletions
diff --git a/weed/server/common.go b/weed/server/common.go
index 2054e1a84..16213689d 100644
--- a/weed/server/common.go
+++ b/weed/server/common.go
@@ -9,6 +9,7 @@ import (
"io/fs"
"mime/multipart"
"net/http"
+ "net/url"
"path/filepath"
"strconv"
"strings"
@@ -250,7 +251,16 @@ func handleStaticResources2(r *mux.Router) {
}
func adjustHeaderContentDisposition(w http.ResponseWriter, r *http.Request, filename string) {
+ responseContentDisposition := r.FormValue("response-content-disposition")
+ if responseContentDisposition != "" {
+ w.Header().Set("Content-Disposition", responseContentDisposition)
+ return
+ }
+ if w.Header().Get("Content-Disposition") != "" {
+ return
+ }
if filename != "" {
+ filename = url.QueryEscape(filename)
contentDisposition := "inline"
if r.FormValue("dl") != "" {
if dl, _ := strconv.ParseBool(r.FormValue("dl")); dl {
diff --git a/weed/server/filer_server_handlers_read.go b/weed/server/filer_server_handlers_read.go
index 9fc9da60f..c24e8780c 100644
--- a/weed/server/filer_server_handlers_read.go
+++ b/weed/server/filer_server_handlers_read.go
@@ -7,7 +7,6 @@ import (
"io"
"mime"
"net/http"
- "net/url"
"path/filepath"
"strconv"
"strings"
@@ -133,7 +132,6 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
setEtag(w, etag)
filename := entry.Name()
- filename = url.QueryEscape(filename)
adjustHeaderContentDisposition(w, r, filename)
totalSize := int64(entry.Size())
diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.go
index 872d83fca..1c230bad3 100644
--- a/weed/server/filer_server_handlers_write_autochunk.go
+++ b/weed/server/filer_server_handlers_write_autochunk.go
@@ -218,7 +218,7 @@ func (fs *FilerServer) saveMetaData(ctx context.Context, r *http.Request, fileNa
entry.Extended = SaveAmzMetaData(r, entry.Extended, false)
for k, v := range r.Header {
- if len(v) > 0 && (strings.HasPrefix(k, needle.PairNamePrefix) || k == "Cache-Control" || k == "Expires") {
+ if len(v) > 0 && (strings.HasPrefix(k, needle.PairNamePrefix) || k == "Cache-Control" || k == "Expires" || k == "Content-Disposition") {
entry.Extended[k] = []byte(v[0])
}
}