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 #218
and #219.
  • Loading branch information
thughes committed Mar 7, 2017
1 parent 2c4c310 commit a62839e
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 a62839e

Please sign in to comment.