aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--x509roots/gen_fallback_bundle.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/x509roots/gen_fallback_bundle.go b/x509roots/gen_fallback_bundle.go
index 80b2044..ec3014f 100644
--- a/x509roots/gen_fallback_bundle.go
+++ b/x509roots/gen_fallback_bundle.go
@@ -17,6 +17,7 @@ import (
"go/format"
"io"
"log"
+ "mime"
"net/http"
"os"
"sort"
@@ -86,6 +87,16 @@ func main() {
log.Fatalf("failed to request %q: %s", *certDataURL, err)
}
defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ body, _ := io.ReadAll(io.LimitReader(resp.Body, 4<<10))
+ log.Fatalf("got non-200 OK status code: %v body: %q", resp.Status, body)
+ } else if ct, want := resp.Header.Get("Content-Type"), `text/plain; charset="UTF-8"`; ct != want {
+ if mediaType, _, err := mime.ParseMediaType(ct); err != nil {
+ log.Fatalf("bad Content-Type header %q: %v", ct, err)
+ } else if mediaType != "text/plain" {
+ log.Fatalf("got media type %q, want %q", mediaType, "text/plain")
+ }
+ }
certdata = resp.Body
}