mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
propagate results of receiving the alt-svc frame, which might arrive just after h2 connection negotiation; for this to be effective, we really have to guarantee negotiation establishment before sending requests, though
This commit is contained in:
parent
94f335fd2f
commit
7f3ca7e8e5
@ -255,6 +255,10 @@ module HTTPX
|
||||
end
|
||||
emit(:response, *args)
|
||||
end
|
||||
parser.on(:altsvc) do |alt_origin, origin, alt_params|
|
||||
emit(:altsvc, alt_origin, origin, alt_params)
|
||||
end
|
||||
|
||||
parser.on(:promise) do |*args|
|
||||
emit(:promise, *args)
|
||||
end
|
||||
|
@ -95,7 +95,7 @@ module HTTPX
|
||||
@connection.on(:frame_sent, &method(:on_frame_sent))
|
||||
@connection.on(:frame_received, &method(:on_frame_received))
|
||||
@connection.on(:promise, &method(:on_promise))
|
||||
@connection.on(:altsvc, &method(:on_altsvc))
|
||||
@connection.on(:altsvc) { |frame| on_altsvc(frame[:origin], frame) }
|
||||
@connection.on(:settings_ack, &method(:on_settings))
|
||||
@connection.on(:goaway, &method(:on_close))
|
||||
end
|
||||
@ -105,7 +105,7 @@ module HTTPX
|
||||
stream.on(:half_close) do
|
||||
log(level: 2, label: "#{stream.id}: ") { "waiting for response..." }
|
||||
end
|
||||
stream.on(:altsvc, &method(:on_altsvc).curry[request.authority])
|
||||
stream.on(:altsvc, &method(:on_altsvc).curry[request.origin])
|
||||
stream.on(:headers, &method(:on_stream_headers).curry[stream, request])
|
||||
stream.on(:data, &method(:on_stream_data).curry[stream, request])
|
||||
end
|
||||
@ -228,14 +228,9 @@ module HTTPX
|
||||
def on_altsvc(origin, frame)
|
||||
log(level: 2, label: "#{frame[:stream]}: ") { "altsvc frame was received" }
|
||||
log(level: 2, label: "#{frame[:stream]}: ") { frame.inspect }
|
||||
origin ||= frame[:origin]
|
||||
alt_proto = frame[:proto]
|
||||
alt_host = frame[:host]
|
||||
alt_port = frame[:port]
|
||||
alt_uri = URI.parse("#{alt_proto}://#{alt_host}:#{alt_port}")
|
||||
log(level: 1, label: "#{frame[:stream]} ") { "#{origin} alt-svc: #{alt_uri}" }
|
||||
alt_origin = URI.parse("#{frame[:proto]}://#{frame[:host]}:#{frame[:port]}")
|
||||
params = { "ma" => frame[:max_age] }
|
||||
emit(:alternate_service, alt_uri, origin, params)
|
||||
emit(:altsvc, origin, alt_origin, origin, params)
|
||||
end
|
||||
|
||||
def on_promise(stream)
|
||||
|
Loading…
x
Reference in New Issue
Block a user