1
0
mirror of https://github.com/golang/go synced 2024-11-24 21:00:09 -07:00

websocket: include *http.Request in websocket.Conn

This permits the websocket handler to inspect http headers and such.

Fixes #1726.

R=ukai, bradfitz, bradfitzgo
CC=golang-dev
https://golang.org/cl/4439069
This commit is contained in:
Andrew Gerrand 2011-04-26 10:47:49 +10:00
parent 079a5cffb3
commit 43b97ce69b
2 changed files with 4 additions and 0 deletions

View File

@ -150,6 +150,7 @@ func (f Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
ws := newConn(origin, location, protocol, buf, rwc)
ws.Request = req
f(ws)
}

View File

@ -13,6 +13,7 @@ import (
"bufio"
"crypto/md5"
"encoding/binary"
"http"
"io"
"net"
"os"
@ -43,6 +44,8 @@ type Conn struct {
Location string
// The subprotocol for the Web Socket.
Protocol string
// The initial http Request (for the Server side only).
Request *http.Request
buf *bufio.ReadWriter
rwc io.ReadWriteCloser