Commit 43b97ce6 authored by Andrew Gerrand's avatar Andrew Gerrand

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
parent 079a5cff
...@@ -150,6 +150,7 @@ func (f Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -150,6 +150,7 @@ func (f Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return return
} }
ws := newConn(origin, location, protocol, buf, rwc) ws := newConn(origin, location, protocol, buf, rwc)
ws.Request = req
f(ws) f(ws)
} }
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"bufio" "bufio"
"crypto/md5" "crypto/md5"
"encoding/binary" "encoding/binary"
"http"
"io" "io"
"net" "net"
"os" "os"
...@@ -43,6 +44,8 @@ type Conn struct { ...@@ -43,6 +44,8 @@ type Conn struct {
Location string Location string
// The subprotocol for the Web Socket. // The subprotocol for the Web Socket.
Protocol string Protocol string
// The initial http Request (for the Server side only).
Request *http.Request
buf *bufio.ReadWriter buf *bufio.ReadWriter
rwc io.ReadWriteCloser rwc io.ReadWriteCloser
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment