Skip to content

Commit

Permalink
Fix GOAWAY deserialization when debug data is present
Browse files Browse the repository at this point in the history
Additional debug data is allowed to be included in the GOAWAY frame:
https://http2.github.io/http2-spec/#GOAWAY. We now put that data into
frame.debug_data instead of returning a FRAME_SIZE_ERROR. Fixes molnarg#218
and molnarg#219.
  • Loading branch information
thughes authored and florianreinhart committed Mar 15, 2017
1 parent 074a654 commit dff41d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/protocol/framer.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,8 @@ typeSpecificAttributes.GOAWAY = ['last_stream', 'error'];
// +-+-------------------------------------------------------------+
// | Error Code (32) |
// +---------------------------------------------------------------+
// | Additional Debug Data (*) |
// +---------------------------------------------------------------+
//
// The last stream identifier in the GOAWAY frame contains the highest numbered stream identifier
// for which the sender of the GOAWAY frame has received frames on and might have taken some action
Expand All @@ -759,8 +761,8 @@ Serializer.GOAWAY = function writeGoaway(frame, buffers) {
};

Deserializer.GOAWAY = function readGoaway(buffer, frame) {
if (buffer.length !== 8) {
// GOAWAY must have 8 bytes
if (buffer.length < 8) {
// GOAWAY must have at least 8 bytes
return 'FRAME_SIZE_ERROR';
}
frame.last_stream = buffer.readUInt32BE(0) & 0x7fffffff;
Expand All @@ -769,6 +771,12 @@ Deserializer.GOAWAY = function readGoaway(buffer, frame) {
// Unknown error types are to be considered equivalent to INTERNAL ERROR
frame.error = 'INTERNAL_ERROR';
}
// Read remaining data into "debug_data"
// https://http2.github.io/http2-spec/#GOAWAY
// Endpoints MAY append opaque data to the payload of any GOAWAY frame
if (buffer.length > 8) {
frame.debug_data = buffer.slice(8);
}
};

// [WINDOW_UPDATE](https://tools.ietf.org/html/rfc7540#section-6.9)
Expand Down

0 comments on commit dff41d9

Please sign in to comment.