mirror of https://github.com/perkeep/perkeep.git
Update for Go's new http.Request.Header type.
This commit is contained in:
parent
6452c5e7da
commit
b021345ed6
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue