diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 21:09:11 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-11 21:09:11 +0900 |
commit | 45517dac41ca3ae0575a936576b7cc6828458244 (patch) | |
tree | 0246b15d62dcabf3b10be7ac03cdac04eb459b34 /lib | |
parent | d581eb29ee7239e84371a7fdf4e89f70b4f176f9 (diff) | |
download | plum-45517dac41ca3ae0575a936576b7cc6828458244.tar.gz |
error: ERROR_CODES should be in HTTPError class
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plum/errors.rb | 35 | ||||
-rw-r--r-- | lib/plum/frame_factory.rb | 4 |
2 files changed, 20 insertions, 19 deletions
diff --git a/lib/plum/errors.rb b/lib/plum/errors.rb index c4c0e39..5b4b565 100644 --- a/lib/plum/errors.rb +++ b/lib/plum/errors.rb @@ -1,25 +1,26 @@ module Plum - ERROR_CODES = { - no_error: 0x00, - protocol_error: 0x01, - internal_error: 0x02, - flow_control_error: 0x03, - settings_timeout: 0x04, - stream_closed: 0x05, - frame_size_error: 0x06, - refused_stream: 0x07, - cancel: 0x08, - compression_error: 0x09, - connect_error: 0x0a, - enhance_your_calm: 0x0b, - inadequate_security: 0x0c, - http_1_1_required: 0x0d - } - class Error < StandardError; end class HPACKError < Error; end class HTTPError < Error + ERROR_CODES = { + no_error: 0x00, + protocol_error: 0x01, + internal_error: 0x02, + flow_control_error: 0x03, + settings_timeout: 0x04, + stream_closed: 0x05, + frame_size_error: 0x06, + refused_stream: 0x07, + cancel: 0x08, + compression_error: 0x09, + connect_error: 0x0a, + enhance_your_calm: 0x0b, + inadequate_security: 0x0c, + http_1_1_required: 0x0d + } + attr_reader :http2_error_type + def initialize(type, message = nil) @http2_error_type = type super(message) diff --git a/lib/plum/frame_factory.rb b/lib/plum/frame_factory.rb index eca31bb..b88cfab 100644 --- a/lib/plum/frame_factory.rb +++ b/lib/plum/frame_factory.rb @@ -3,13 +3,13 @@ using Plum::BinaryString module Plum module FrameFactory def rst_stream(stream_id, error_type) - payload = "".push_uint32(ERROR_CODES[error_type]) + payload = "".push_uint32(HTTPError::ERROR_CODES[error_type]) Frame.new(type: :rst_stream, stream_id: stream_id, payload: payload) end def goaway(last_id, error_type, message = "") payload = "".push_uint32((last_id || 0) | (0 << 31)) - .push_uint32(ERROR_CODES[error_type]) + .push_uint32(HTTPError::ERROR_CODES[error_type]) .push(message) Frame.new(type: :goaway, stream_id: 0, payload: payload) end |