-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add http2.remote_settings to gun:info map #247
base: master
Are you sure you want to change the base?
Add http2.remote_settings to gun:info map #247
Conversation
An example of what this looks like:
|
Yeah, that's not good though because of the possibility for proxies. HTTP/2 CONNECT support is about to be merged and I'll need to think a little more about how best to handle this considering there might be multiple layers of settings. Also this should not single out HTTP/2 because we will need to do the same for HTTP/3 later. Please hold until the |
Websocket over HTTP/2 will also make knowing settings useful, one way or another. Hold on a little bit more and I'll get back to this. |
Something like this would be more appropriate: diff --git a/src/gun.erl b/src/gun.erl
index e441e52..7e77da3 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -464,6 +464,7 @@ info(ServerPid) ->
origin_host=OriginHost,
origin_port=OriginPort,
intermediaries=Intermediaries,
+ protocol_state=ProtoState,
cookie_store=CookieStore
}} = sys:get_state(ServerPid),
Info0 = #{
@@ -497,8 +498,17 @@ info(ServerPid) ->
end
end,
case Protocol of
- undefined -> Info;
- _ -> Info#{protocol => Protocol:name()}
+ undefined ->
+ Info;
+ gun_http2 ->
+ Info#{
+ protocol => Protocol:name(),
+ %% @todo In the future we can generalize this to other protocols.
+ %% We can also add this to stream_info when the stream is a tunnel.
+ http2_info => gun_http2:info(ProtoState)
+ };
+ _ ->
+ Info#{protocol => Protocol:name()}
end.
%% We change tls_proxy into tls for intermediaries.
diff --git a/src/gun_http2.erl b/src/gun_http2.erl
index 8f0632b..52ac93b 100644
--- a/src/gun_http2.erl
+++ b/src/gun_http2.erl
@@ -33,6 +33,7 @@
-export([connect/9]).
-export([cancel/5]).
-export([timeout/3]).
+-export([info/1]).
-export([stream_info/2]).
-export([down/1]).
-export([ws_upgrade/11]).
@@ -1247,6 +1248,11 @@ timeout(State, {cow_http2_machine, RealStreamRef, Name}, TRef) ->
{state, State}
end.
+info(#http2_state{http2_machine=HTTP2Machine}) ->
+ #{
+ remote_settings => cow_http2_machine:get_remote_settings(HTTP2Machine)
+ }.
+
stream_info(State, StreamRef) when is_reference(StreamRef) ->
case get_stream_by_ref(State, StreamRef) of
#stream{reply_to=ReplyTo, tunnel=#tunnel{destination=Destination, Also this needs a test added to gun_SUITE that checks that http2_info are set, and the http2_info key needs to be added to the gun.info.asciidoc manual page. |
This adds a new http2 entry to the info map, with a remote_settings property.
Depends on: ninenines/cowlib#107