From 1300b213f241779229d549932e1a78a2d536accb Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 23 Feb 2011 17:56:40 -0800 Subject: [PATCH] Update for Go's new http.Request.Header type. --- lib/go/httprange/range.go | 4 ++-- server/go/auth/auth.go | 4 ++-- website/cgi.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/go/httprange/range.go b/lib/go/httprange/range.go index ed7ad67e0..6531b9409 100644 --- a/lib/go/httprange/range.go +++ b/lib/go/httprange/range.go @@ -46,8 +46,8 @@ var WholeRange = &Range{0, -1} var rangePattern = regexp.MustCompile(`bytes=([0-9]+)-([0-9]*)`) func FromRequest(req *http.Request) *Range { - rrange, ok := req.Header["Range"] - if !ok { + rrange := req.Header.Get("Range") + if rrange == "" { return WholeRange } return FromString(rrange) diff --git a/server/go/auth/auth.go b/server/go/auth/auth.go index a8b7ce610..8bf7b5302 100644 --- a/server/go/auth/auth.go +++ b/server/go/auth/auth.go @@ -29,8 +29,8 @@ var kBasicAuthPattern *regexp.Regexp = regexp.MustCompile(`^Basic ([a-zA-Z0-9\+/ var AccessPassword string func IsAuthorized(req *http.Request) bool { - auth, present := req.Header["Authorization"] - if !present { + auth := req.Header.Get("Authorization") + if auth == "" { return false } matches := kBasicAuthPattern.FindStringSubmatch(auth) diff --git a/website/cgi.go b/website/cgi.go index f72e36c92..0852bce6e 100644 --- a/website/cgi.go +++ b/website/cgi.go @@ -69,15 +69,15 @@ func (h *CgiHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { "SERVER_PORT=" + port, } - for k, v := range req.Header { + for k, _ := range req.Header { k = strings.Map(upperCaseAndUnderscore, k) - env = append(env, "HTTP_"+k+"="+v) + env = append(env, "HTTP_"+k+"="+req.Header.Get(k)) } if req.ContentLength > 0 { env = append(env, fmt.Sprintf("CONTENT_LENGTH=%d", req.ContentLength)) } - if ctype, ok := req.Header["Content-Type"]; ok { + if ctype := req.Header.Get("Content-Type"); ctype != "" { env = append(env, "CONTENT_TYPE="+ctype) }