diff options
Diffstat (limited to 'lib/plum/frame/goaway.rb')
-rw-r--r-- | lib/plum/frame/goaway.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/plum/frame/goaway.rb b/lib/plum/frame/goaway.rb new file mode 100644 index 0000000..e1e0097 --- /dev/null +++ b/lib/plum/frame/goaway.rb @@ -0,0 +1,20 @@ +# frozen-string-literal: true + +using Plum::BinaryString +module Plum + class Frame::Goaway < Frame + register_subclass 0x07 + + # Creates a GOAWAY frame. + # @param last_id [Integer] The biggest processed stream ID. + # @param error_type [Symbol] The error type defined in RFC 7540 Section 7. + # @param message [String] Additional debug data. + # @see RFC 7540 Section 6.8 + def initialize(last_id, error_type, message = "") + payload = String.new.push_uint32(last_id) + .push_uint32(HTTPError::ERROR_CODES[error_type]) + .push(message) + initialize_base(type: :goaway, stream_id: 0, payload: payload) + end + end +end |