Browse Source

Verify num written bytes from body.Write

Brad Fitzpatrick 11 years ago
parent
commit
0218ba6a8f
1 changed files with 5 additions and 2 deletions
  1. 5 2
      server.go

+ 5 - 2
server.go

@@ -1069,10 +1069,13 @@ func (sc *serverConn) processData(f *DataFrame) error {
 	if len(data) > 0 {
 	if len(data) > 0 {
 		// TODO: verify they're allowed to write with the flow control
 		// TODO: verify they're allowed to write with the flow control
 		// window we'd advertised to them.
 		// window we'd advertised to them.
-		// TODO: verify n from Write
-		if _, err := st.body.Write(data); err != nil {
+		wrote, err := st.body.Write(data)
+		if err != nil {
 			return StreamError{id, ErrCodeStreamClosed}
 			return StreamError{id, ErrCodeStreamClosed}
 		}
 		}
+		if wrote != len(data) {
+			panic("internal error: bad Writer")
+		}
 		st.bodyBytes += int64(len(data))
 		st.bodyBytes += int64(len(data))
 	}
 	}
 	if f.StreamEnded() {
 	if f.StreamEnded() {