aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum/connection.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-09 21:19:36 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-09 21:19:36 +0900
commit40e700d3d85b372e64a1eac3c6661e766cf49423 (patch)
tree1c57e4c147d90eedd467124d813e8326fe6ded3b /lib/plum/connection.rb
parent3b460e375507e5393994b3e82a19253d5d0bcddd (diff)
downloadplum-40e700d3d85b372e64a1eac3c6661e766cf49423.tar.gz
client: support HTTP/1.1 upgrade
Diffstat (limited to 'lib/plum/connection.rb')
-rw-r--r--lib/plum/connection.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/plum/connection.rb b/lib/plum/connection.rb
index c31836a..f158560 100644
--- a/lib/plum/connection.rb
+++ b/lib/plum/connection.rb
@@ -58,19 +58,9 @@ module Plum
end
alias << receive
- private
- def consume_buffer
- while frame = Frame.parse!(@buffer)
- callback(:frame, frame)
- receive_frame(frame)
- end
- end
-
- def send_immediately(frame)
- callback(:send_frame, frame)
- @writer.call(frame.assemble)
- end
-
+ # Returns a Stream object with the specified ID.
+ # @param stream_id [Integer] the stream id
+ # @return [Stream] the stream
def stream(stream_id)
raise ArgumentError, "stream_id can't be 0" if stream_id == 0
@@ -92,6 +82,19 @@ module Plum
stream
end
+ private
+ def consume_buffer
+ while frame = Frame.parse!(@buffer)
+ callback(:frame, frame)
+ receive_frame(frame)
+ end
+ end
+
+ def send_immediately(frame)
+ callback(:send_frame, frame)
+ @writer.call(frame.assemble)
+ end
+
def validate_received_frame(frame)
if @state == :waiting_settings && frame.type != :settings
raise RemoteConnectionError.new(:protocol_error)