|
|
@@ -56,11 +56,6 @@ func newTLSServer(t *testing.T) *cstServer {
|
|
|
}
|
|
|
|
|
|
func (t cstHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
|
- if r.Method != "GET" {
|
|
|
- t.Logf("method %s not allowed", r.Method)
|
|
|
- http.Error(w, "method not allowed", 405)
|
|
|
- return
|
|
|
- }
|
|
|
subprotos := Subprotocols(r)
|
|
|
if !reflect.DeepEqual(subprotos, cstDialer.Subprotocols) {
|
|
|
t.Logf("subprotols=%v, want %v", subprotos, cstDialer.Subprotocols)
|
|
|
@@ -287,6 +282,26 @@ func TestDialBadHeader(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestBadMethod(t *testing.T) {
|
|
|
+ s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ ws, err := cstUpgrader.Upgrade(w, r, nil)
|
|
|
+ if err == nil {
|
|
|
+ t.Errorf("handshake succeeded, expect fail")
|
|
|
+ ws.Close()
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ defer s.Close()
|
|
|
+
|
|
|
+ resp, err := http.PostForm(s.URL, url.Values{})
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("PostForm returned error %v", err)
|
|
|
+ }
|
|
|
+ resp.Body.Close()
|
|
|
+ if resp.StatusCode != http.StatusMethodNotAllowed {
|
|
|
+ t.Errorf("Status = %d, want %d", resp.StatusCode, http.StatusMethodNotAllowed)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestHandshake(t *testing.T) {
|
|
|
s := newServer(t)
|
|
|
defer s.Close()
|