aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum/stream.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-08 21:31:17 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-08 22:02:50 +0900
commit0afb9eadcbb5e631757a777124281f663d8f6974 (patch)
tree53a02042e57eb390021221f95ec1637c47b1099e /lib/plum/stream.rb
parent57a2e245f6021c5e41610353c3c47c108a43d908 (diff)
downloadplum-0afb9eadcbb5e631757a777124281f663d8f6974.tar.gz
avoid Frame#type if possible
For typo-safety.
Diffstat (limited to 'lib/plum/stream.rb')
-rw-r--r--lib/plum/stream.rb28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/plum/stream.rb b/lib/plum/stream.rb
index 420ee23..6e6724e 100644
--- a/lib/plum/stream.rb
+++ b/lib/plum/stream.rb
@@ -31,22 +31,15 @@ module Plum
validate_received_frame(frame)
consume_recv_window(frame)
- case frame.type
- when :data
- receive_data(frame)
- when :headers
- receive_headers(frame)
- when :priority
- receive_priority(frame)
- when :rst_stream
- receive_rst_stream(frame)
- when :window_update
- receive_window_update(frame)
- when :continuation
- receive_continuation(frame)
- when :push_promise
- receive_push_promise(frame)
- when :ping, :goaway, :settings
+ case frame
+ when Frame::Data then receive_data(frame)
+ when Frame::Headers then receive_headers(frame)
+ when Frame::Priority then receive_priority(frame)
+ when Frame::RstStream then receive_rst_stream(frame)
+ when Frame::WindowUpdate then receive_window_update(frame)
+ when Frame::Continuation then receive_continuation(frame)
+ when Frame::PushPromise then receive_push_promise(frame)
+ when Frame::Ping, Frame::Goaway, Frame::Settings
raise RemoteConnectionError.new(:protocol_error) # stream_id MUST be 0x00
else
# MUST ignore unknown frame
@@ -135,7 +128,8 @@ module Plum
def validate_received_frame(frame)
if frame.length > @connection.local_settings[:max_frame_size]
- if [:headers, :push_promise, :continuation].include?(frame.type)
+ case frame
+ when Frame::Headers, Frame::PushPromise, Frame::Continuation
raise RemoteConnectionError.new(:frame_size_error)
else
raise RemoteStreamError.new(:frame_size_error)