[mirror] Scalable static site server for Git forges (like GitHub Pages)

Fix several content type negotiation issues.

* No `Accept:` header should be the same as `Accept: */*`.
* For unresolved reference error, `text/plain` should take priority.

Changed files
+5 -2
src
+4 -1
src/http.go
··· 55 55 } 56 56 57 57 func ParseAcceptHeader(headerValue string) (result HTTPContentTypes) { 58 + if headerValue == "" { 59 + headerValue = "*/*" 60 + } 58 61 result = HTTPContentTypes{parseGenericAcceptHeader(headerValue)} 59 62 return 60 63 } ··· 65 68 prefs[code] = 0 66 69 } 67 70 for _, ctyp := range e.contentTypes { 68 - if ctyp.code == "*" || ctyp.code == "*/*" { 71 + if ctyp.code == "*/*" { 69 72 for code := range prefs { 70 73 prefs[code] = ctyp.qval 71 74 }
+1 -1
src/pages.go
··· 575 575 func reportUpdateResult(w http.ResponseWriter, r *http.Request, result UpdateResult) error { 576 576 var unresolvedRefErr UnresolvedRefError 577 577 if result.outcome == UpdateError && errors.As(result.err, &unresolvedRefErr) { 578 - offeredContentTypes := []string{"application/vnd.git-pages.unresolved", "text/plain"} 578 + offeredContentTypes := []string{"text/plain", "application/vnd.git-pages.unresolved"} 579 579 acceptedContentTypes := ParseAcceptHeader(r.Header.Get("Accept")) 580 580 switch acceptedContentTypes.Negotiate(offeredContentTypes...) { 581 581 default: