summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/plum/stream_utils.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/plum/stream_utils.rb b/lib/plum/stream_utils.rb
index 0bcceec..44ed945 100644
--- a/lib/plum/stream_utils.rb
+++ b/lib/plum/stream_utils.rb
@@ -2,9 +2,9 @@ using Plum::BinaryString
module Plum
module StreamUtils
- # Responds to HTTP request.
+ # Responds to a HTTP request.
#
- # @param headers [Hash<String, String>] The response headers.
+ # @param headers [Enumerable<String, String>] The response headers.
# @param body [String, IO] The response body.
def respond(headers, body = nil, end_stream: true) # TODO: priority, padding
if body
@@ -17,7 +17,7 @@ module Plum
# Reserves a stream to server push. Sends PUSH_PROMISE and create new stream.
#
- # @param headers [Hash<String, String>] The *request* headers. It must contain all of them: ':authority', ':method', ':scheme' and ':path'.
+ # @param headers [Enumerable<String, String>] The *request* headers. It must contain all of them: ':authority', ':method', ':scheme' and ':path'.
# @return [Stream] The stream to send push response.
def promise(headers)
stream = @connection.reserve_stream(weight: self.weight + 1, parent: self)
@@ -29,7 +29,10 @@ module Plum
stream
end
- private
+ # Sends response headers. If the encoded frame is larger than MAX_FRAME_SIZE, the headers will be splitted into HEADERS frame and CONTINUATION frame(s).
+ #
+ # @param headers [Enumerable<String, String>] The response headers.
+ # @param end_stream [Boolean] Set END_STREAM flag or not.
def send_headers(headers, end_stream:)
max = @connection.remote_settings[:max_frame_size]
encoded = @connection.hpack_encoder.encode(headers)
@@ -40,6 +43,10 @@ module Plum
@state = :half_closed_local if end_stream
end
+ # Sends DATA frame. If the data is larger than MAX_FRAME_SIZE, DATA frame will be splitted.
+ #
+ # @param data [String, IO] The data to send.
+ # @param end_stream [Boolean] Set END_STREAM flag or not.
def send_data(data, end_stream: true)
max = @connection.remote_settings[:max_frame_size]
if data.is_a?(IO)