+8
-10
src/pages.go
+8
-10
src/pages.go
···
8
8
"fmt"
9
9
"io"
10
10
"log"
11
-
"mime"
12
11
"net/http"
13
12
"net/url"
14
13
"os"
···
282
281
w.Header().Set("Content-Type", *entry.ContentType)
283
282
}
284
283
285
-
// allow the use of multi-threading in WebAssembly
286
-
w.Header().Set("Cross-Origin-Embedder-Policy", "credentialless")
287
-
w.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
284
+
contentType := getMediaType(entry.GetContentType())
285
+
if contentType == "" || contentType == "text/html" || contentType == "application/xhtml+xml" {
286
+
// allow the use of multi-threading in WebAssembly
287
+
w.Header().Set("Cross-Origin-Embedder-Policy", "credentialless")
288
+
w.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
289
+
}
288
290
289
291
// consider content fresh for 60 seconds (the same as the freshness interval of
290
292
// manifests in the S3 backend), and use stale content anyway as long as it's not
···
315
317
316
318
webRoot := makeWebRoot(host, projectName)
317
319
318
-
contentType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
319
-
if err != nil {
320
-
http.Error(w, "malformed content type", http.StatusUnsupportedMediaType)
321
-
return fmt.Errorf("content type: %w", err)
322
-
}
323
-
324
320
updateCtx, cancel := context.WithTimeout(r.Context(), time.Duration(config.Limits.UpdateTimeout))
325
321
defer cancel()
322
+
323
+
contentType := getMediaType(r.Header.Get("Content-Type"))
326
324
327
325
if contentType == "application/x-www-form-urlencoded" {
328
326
auth, err := AuthorizeUpdateFromRepository(r)