Browse Source

Send GOAWAY if server receives a PUSH_PROMISE.

Daniel Morsing 11 years ago
parent
commit
9f25169dc9
2 changed files with 16 additions and 0 deletions
  1. 4 0
      server.go
  2. 12 0
      server_test.go

+ 4 - 0
server.go

@@ -820,6 +820,10 @@ func (sc *serverConn) processFrame(f Frame) error {
 		return sc.processResetStream(f)
 		return sc.processResetStream(f)
 	case *PriorityFrame:
 	case *PriorityFrame:
 		return sc.processPriority(f)
 		return sc.processPriority(f)
+	case *PushPromiseFrame:
+		// A client cannot push. Thus, servers MUST treat the receipt of a PUSH_PROMISE
+		// frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.
+		return ConnectionError(ErrCodeProtocol)
 	default:
 	default:
 		log.Printf("Ignoring frame: %v", f.Header())
 		log.Printf("Ignoring frame: %v", f.Header())
 		return nil
 		return nil

+ 12 - 0
server_test.go

@@ -1091,6 +1091,18 @@ func TestServer_Rejects_Continuation0(t *testing.T) {
 	})
 	})
 }
 }
 
 
+func TestServer_Rejects_PushPromise(t *testing.T) {
+	testServerRejects(t, func(st *serverTester) {
+		pp := PushPromiseParam{
+			StreamID:  1,
+			PromiseID: 3,
+		}
+		if err := st.fr.WritePushPromise(pp); err != nil {
+			t.Fatal(err)
+		}
+	})
+}
+
 // testServerRejects tests that the server hangs up with a GOAWAY
 // testServerRejects tests that the server hangs up with a GOAWAY
 // frame and a server close after the client does something
 // frame and a server close after the client does something
 // deserving a CONNECTION_ERROR.
 // deserving a CONNECTION_ERROR.