diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2017-10-04 09:48:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-04 09:48:36 -0400 |
commit | bd2542b74fe528d95f51d8f3668b0f7d6d8af974 (patch) | |
tree | 9a0fbb2d0fe7c978172aede8117401cbf3b48b36 /actionpack/lib | |
parent | df2814671cce80fd0d8f290e5a70bf518880d6fa (diff) | |
parent | 59a02fb7bcbe68f26e1e7fdcec45c00c66e4a065 (diff) | |
download | rails-bd2542b74fe528d95f51d8f3668b0f7d6d8af974.tar.gz rails-bd2542b74fe528d95f51d8f3668b0f7d6d8af974.tar.bz2 rails-bd2542b74fe528d95f51d8f3668b0f7d6d8af974.zip |
Merge pull request #30744 from eileencodes/early-hints
Implement H2 Early Hints for Rails
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index dee7be184a..5c172aecad 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -199,6 +199,23 @@ module ActionDispatch @headers ||= Http::Headers.new(self) end + # Early Hints is an HTTP/2 status code that indicates hints to help a client start + # making preparations for processing the final response. + # + # If the env contains +rack.early_hints+ then the server accepts HTTP2 push for Link headers. + # + # The +send_early_hints+ method accepts an hash of links as follows: + # + # send_early_hints("Link" => "</style.css>; rel=preload; as=style\n</script.js>; rel=preload") + # + # If you are using +javascript_include_tag+ or +stylesheet_link_tag+ the + # Early Hints headers are included by default if supported. + def send_early_hints(links) + return unless env["rack.early_hints"] + + env["rack.early_hints"].call(links) + end + # Returns a +String+ with the last requested path including their params. # # # get '/foo' |