lib/async/http/protocol/http2/stream.rb in async-http-0.76.0 vs lib/async/http/protocol/http2/stream.rb in async-http-0.77.0
- old
+ new
@@ -3,14 +3,14 @@
# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
# Copyright, 2022, by Marco Concetto Rudilosso.
# Copyright, 2023, by Thomas Morgan.
-require 'protocol/http2/stream'
+require "protocol/http2/stream"
-require_relative 'input'
-require_relative 'output'
+require_relative "input"
+require_relative "output"
module Async
module HTTP
module Protocol
module HTTP2
@@ -18,26 +18,30 @@
def initialize(*)
super
@headers = nil
+ @pool = nil
+
# Input buffer, reading request body, or response body (receive_data):
@length = nil
@input = nil
# Output buffer, writing request body or response body (window_updated):
@output = nil
end
attr_accessor :headers
+ attr_accessor :pool
+
attr :input
def add_header(key, value)
if key == CONNECTION
raise ::Protocol::HTTP2::HeaderError, "Connection header is not allowed!"
- elsif key.start_with? ':'
+ elsif key.start_with? ":"
raise ::Protocol::HTTP2::HeaderError, "Invalid pseudo-header #{key}!"
elsif key =~ /[A-Z]/
raise ::Protocol::HTTP2::HeaderError, "Invalid upper-case characters in header #{key}!"
else
@headers.add(key, value)
@@ -154,9 +158,13 @@
end
if @output
@output.stop(error)
@output = nil
+ end
+
+ if pool = @pool and @connection
+ pool.release(@connection)
end
return self
end
end