http: introduce Header type, implement with net/textproto

textproto: introduce Header type
websocket: use new interface to access Header

R=rsc, mattn
CC=golang-dev
https://golang.org/cl/4185053
This commit is contained in:
Petar Maymounkov 2011-02-23 00:39:25 -05:00 committed by Russ Cox
parent 07cc8b9ad2
commit b8fa61885a
20 changed files with 263 additions and 335 deletions

View file

@ -245,20 +245,20 @@ func handshake(resourceName, host, origin, location, protocol string, br *bufio.
}
// Step 41. check websocket headers.
if resp.Header["Upgrade"] != "WebSocket" ||
strings.ToLower(resp.Header["Connection"]) != "upgrade" {
if resp.Header.Get("Upgrade") != "WebSocket" ||
strings.ToLower(resp.Header.Get("Connection")) != "upgrade" {
return ErrBadUpgrade
}
if resp.Header["Sec-Websocket-Origin"] != origin {
if resp.Header.Get("Sec-Websocket-Origin") != origin {
return ErrBadWebSocketOrigin
}
if resp.Header["Sec-Websocket-Location"] != location {
if resp.Header.Get("Sec-Websocket-Location") != location {
return ErrBadWebSocketLocation
}
if protocol != "" && resp.Header["Sec-Websocket-Protocol"] != protocol {
if protocol != "" && resp.Header.Get("Sec-Websocket-Protocol") != protocol {
return ErrBadWebSocketProtocol
}
@ -304,17 +304,17 @@ func draft75handshake(resourceName, host, origin, location, protocol string, br
if resp.Status != "101 Web Socket Protocol Handshake" {
return ErrBadStatus
}
if resp.Header["Upgrade"] != "WebSocket" ||
resp.Header["Connection"] != "Upgrade" {
if resp.Header.Get("Upgrade") != "WebSocket" ||
resp.Header.Get("Connection") != "Upgrade" {
return ErrBadUpgrade
}
if resp.Header["Websocket-Origin"] != origin {
if resp.Header.Get("Websocket-Origin") != origin {
return ErrBadWebSocketOrigin
}
if resp.Header["Websocket-Location"] != location {
if resp.Header.Get("Websocket-Location") != location {
return ErrBadWebSocketLocation
}
if protocol != "" && resp.Header["Websocket-Protocol"] != protocol {
if protocol != "" && resp.Header.Get("Websocket-Protocol") != protocol {
return ErrBadWebSocketProtocol
}
return