Expose content type also via X-Content-Type header
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ export function headersToFileMeta(
|
||||
size: headers.has("X-Content-Length")
|
||||
? +headers.get("X-Content-Length")!
|
||||
: +headers.get("Content-Length")!,
|
||||
contentType: headers.get("Content-type")!,
|
||||
contentType: headers.get("X-Content-Type") ?? headers.get("Content-type")!,
|
||||
created: +(headers.get("X-Created") || "0"),
|
||||
lastModified: +(headers.get("X-Last-Modified") || "0"),
|
||||
perm: (headers.get("X-Permission") as "rw" | "ro") || "ro",
|
||||
|
||||
+6
-1
@@ -135,6 +135,7 @@ func handleFsDelete(w http.ResponseWriter, r *http.Request) {
|
||||
// setFileMetaHeaders sets HTTP headers based on FileMeta
|
||||
func setFileMetaHeaders(w http.ResponseWriter, meta FileMeta) {
|
||||
w.Header().Set("Content-Type", meta.ContentType)
|
||||
w.Header().Set("X-Content-Type", meta.ContentType)
|
||||
w.Header().Set("X-Created", strconv.FormatInt(meta.Created, 10))
|
||||
w.Header().Set("X-Last-Modified", strconv.FormatInt(meta.LastModified, 10))
|
||||
w.Header().Set("X-Content-Length", strconv.FormatInt(meta.Size, 10))
|
||||
@@ -146,9 +147,13 @@ func setFileMetaHeaders(w http.ResponseWriter, meta FileMeta) {
|
||||
func getFileMetaFromHeaders(h http.Header, path string) *FileMeta {
|
||||
var err error
|
||||
|
||||
contentType := h.Get("X-Content-Type")
|
||||
if contentType == "" {
|
||||
contentType = h.Get("Content-Type")
|
||||
}
|
||||
fm := &FileMeta{
|
||||
Name: path,
|
||||
ContentType: h.Get("Content-Type"),
|
||||
ContentType: contentType,
|
||||
Perm: h.Get("X-Permission"),
|
||||
}
|
||||
if fm.Perm == "" {
|
||||
|
||||
Reference in New Issue
Block a user