mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-08 00:02:42 -04:00
push promise stream callback is now as upper-level as it can get; this allows it to be redefined better
This commit is contained in:
parent
10146be1bc
commit
3ffbed8a30
@ -202,9 +202,7 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def on_promise(stream)
|
def on_promise(stream)
|
||||||
log(2, "#{stream.id}: ") { "refusing stream!" }
|
emit(:promise, stream)
|
||||||
stream.refuse
|
|
||||||
# TODO: policy for handling promises
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(meth, *args, &blk)
|
def method_missing(meth, *args, &blk)
|
||||||
|
@ -39,6 +39,12 @@ module HTTPX
|
|||||||
@responses[request] = response
|
@responses[request] = response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def on_promise(stream)
|
||||||
|
log(2, "#{stream.id}: ") { "refusing stream!" }
|
||||||
|
stream.refuse
|
||||||
|
# TODO: policy for handling promises
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_response(request)
|
def fetch_response(request)
|
||||||
response = @responses.delete(request)
|
response = @responses.delete(request)
|
||||||
if response.is_a?(ErrorResponse) && response.retryable?
|
if response.is_a?(ErrorResponse) && response.retryable?
|
||||||
@ -51,8 +57,16 @@ module HTTPX
|
|||||||
|
|
||||||
def find_channel(request)
|
def find_channel(request)
|
||||||
uri = URI(request.uri)
|
uri = URI(request.uri)
|
||||||
@connection.find_channel(uri) ||
|
@connection.find_channel(uri) || begin
|
||||||
@connection.build_channel(uri, &method(:on_response))
|
channel = @connection.build_channel(uri)
|
||||||
|
set_channel_callbacks(channel)
|
||||||
|
channel
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_channel_callbacks(channel)
|
||||||
|
channel.on(:response, &method(:on_response))
|
||||||
|
channel.on(:promise, &method(:on_promise))
|
||||||
end
|
end
|
||||||
|
|
||||||
def __build_reqs(*args, **options)
|
def __build_reqs(*args, **options)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user