http2: emiting parser as well, as it makes writing custom logic easier

This commit is contained in:
HoneyryderChuck 2018-01-13 21:42:13 +00:00
parent 761ecb800d
commit 9a3f816e46
2 changed files with 5 additions and 3 deletions

View File

@ -7,6 +7,8 @@ module HTTPX
include Callbacks
include Loggable
attr_reader :streams, :pending
def initialize(buffer, options)
@options = Options.new(options)
@max_concurrent_requests = @options.max_concurrent_requests
@ -94,7 +96,7 @@ module HTTPX
if request.expects?
return handle(request, stream)
end
response = request.response || ErrorResponse.new(error, retries)
response = request.response || ErrorResponse.new(error, @retries)
emit(:response, request, response)
log(2, "#{stream.id}: ") { "closing stream" }
@ -202,7 +204,7 @@ module HTTPX
end
def on_promise(stream)
emit(:promise, stream)
emit(:promise, self, stream)
end
def method_missing(meth, *args, &blk)

View File

@ -39,7 +39,7 @@ module HTTPX
@responses[request] = response
end
def on_promise(stream)
def on_promise(_, stream)
log(2, "#{stream.id}: ") { "refusing stream!" }
stream.refuse
# TODO: policy for handling promises