+8
-10
src/pages.go
+8
-10
src/pages.go
···
8
"fmt"
9
"io"
10
"log"
11
-
"mime"
12
"net/http"
13
"net/url"
14
"os"
···
282
w.Header().Set("Content-Type", *entry.ContentType)
283
}
284
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")
288
289
// consider content fresh for 60 seconds (the same as the freshness interval of
290
// manifests in the S3 backend), and use stale content anyway as long as it's not
···
315
316
webRoot := makeWebRoot(host, projectName)
317
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
updateCtx, cancel := context.WithTimeout(r.Context(), time.Duration(config.Limits.UpdateTimeout))
325
defer cancel()
326
327
if contentType == "application/x-www-form-urlencoded" {
328
auth, err := AuthorizeUpdateFromRepository(r)
···
8
"fmt"
9
"io"
10
"log"
11
"net/http"
12
"net/url"
13
"os"
···
281
w.Header().Set("Content-Type", *entry.ContentType)
282
}
283
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
+
}
290
291
// consider content fresh for 60 seconds (the same as the freshness interval of
292
// manifests in the S3 backend), and use stale content anyway as long as it's not
···
317
318
webRoot := makeWebRoot(host, projectName)
319
320
updateCtx, cancel := context.WithTimeout(r.Context(), time.Duration(config.Limits.UpdateTimeout))
321
defer cancel()
322
+
323
+
contentType := getMediaType(r.Header.Get("Content-Type"))
324
325
if contentType == "application/x-www-form-urlencoded" {
326
auth, err := AuthorizeUpdateFromRepository(r)
+6
src/util.go
+6
src/util.go