mirror of
https://github.com/golang/go
synced 2024-11-22 03:34:40 -07:00
websocket: use httptest.Server for tests
R=rsc CC=golang-dev https://golang.org/cl/4266044
This commit is contained in:
parent
59d2acd2d4
commit
ce65b72508
@ -9,6 +9,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"http"
|
"http"
|
||||||
|
"http/httptest"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -22,15 +23,11 @@ var once sync.Once
|
|||||||
func echoServer(ws *Conn) { io.Copy(ws, ws) }
|
func echoServer(ws *Conn) { io.Copy(ws, ws) }
|
||||||
|
|
||||||
func startServer() {
|
func startServer() {
|
||||||
l, e := net.Listen("tcp", "127.0.0.1:0") // any available address
|
|
||||||
if e != nil {
|
|
||||||
log.Fatalf("net.Listen tcp :0 %v", e)
|
|
||||||
}
|
|
||||||
serverAddr = l.Addr().String()
|
|
||||||
log.Print("Test WebSocket server listening on ", serverAddr)
|
|
||||||
http.Handle("/echo", Handler(echoServer))
|
http.Handle("/echo", Handler(echoServer))
|
||||||
http.Handle("/echoDraft75", Draft75Handler(echoServer))
|
http.Handle("/echoDraft75", Draft75Handler(echoServer))
|
||||||
go http.Serve(l, nil)
|
server := httptest.NewServer(nil)
|
||||||
|
serverAddr = server.Listener.Addr().String()
|
||||||
|
log.Print("Test WebSocket server listening on ", serverAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the getChallengeResponse function with values from section
|
// Test the getChallengeResponse function with values from section
|
||||||
|
Loading…
Reference in New Issue
Block a user