Update for Go's new http.Request.Header type.

This commit is contained in:
Brad Fitzpatrick 2011-02-23 17:56:40 -08:00
parent da9a0da296
commit 1300b213f2
3 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)
}