summaryrefslogtreecommitdiff
path: root/libgo/go/websocket/websocket_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/websocket/websocket_test.go')
-rw-r--r--libgo/go/websocket/websocket_test.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/libgo/go/websocket/websocket_test.go b/libgo/go/websocket/websocket_test.go
index 69b5335cfa9..f41c355fac2 100644
--- a/libgo/go/websocket/websocket_test.go
+++ b/libgo/go/websocket/websocket_test.go
@@ -7,15 +7,15 @@ package websocket
import (
"bytes"
"fmt"
- "http"
- "http/httptest"
"io"
"log"
"net"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
"strings"
"sync"
"testing"
- "url"
)
var serverAddr string
@@ -200,20 +200,19 @@ func TestHTTP(t *testing.T) {
once.Do(startServer)
// If the client did not send a handshake that matches the protocol
- // specification, the server should abort the WebSocket connection.
- _, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
- if err == nil {
- t.Error("Get: unexpected success")
+ // specification, the server MUST return an HTTP respose with an
+ // appropriate error code (such as 400 Bad Request)
+ resp, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr))
+ if err != nil {
+ t.Errorf("Get: error %#v", err)
return
}
- urlerr, ok := err.(*url.Error)
- if !ok {
- t.Errorf("Get: not url.Error %#v", err)
+ if resp == nil {
+ t.Error("Get: resp is null")
return
}
- if urlerr.Err != io.ErrUnexpectedEOF {
- t.Errorf("Get: error %#v", err)
- return
+ if resp.StatusCode != http.StatusBadRequest {
+ t.Errorf("Get: expected %q got %q", http.StatusBadRequest, resp.StatusCode)
}
}