diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-10-26 21:12:16 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-10-26 21:12:16 +0900 |
commit | dd5209c919a52ce0a026f006b65dc9041ecedd7b (patch) | |
tree | 549aaadcb6eb71345880206eae67403a114c4f04 | |
parent | ff7e81f4aba4995633b91adf0bbb8e45a6357444 (diff) | |
download | plum-dd5209c919a52ce0a026f006b65dc9041ecedd7b.tar.gz |
rack: don't HTTP/2 Server Push if disabled in config or peer SETTINGS
-rw-r--r-- | lib/plum/rack/connection.rb | 7 | ||||
-rw-r--r-- | lib/plum/rack/server.rb | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/plum/rack/connection.rb b/lib/plum/rack/connection.rb index 0c53e3d..75569c7 100644 --- a/lib/plum/rack/connection.rb +++ b/lib/plum/rack/connection.rb @@ -6,10 +6,11 @@ module Plum class Connection attr_reader :app, :plum - def initialize(app, plum, logger) + def initialize(app, plum, logger, server_push:) @app = app @plum = plum @logger = logger + @server_push = server_push setup_plum end @@ -69,7 +70,9 @@ module Plum end def extract_push(reqheaders, extheaders) - if pushs = extheaders["plum.serverpush"] + if @server_push && + @plum.push_enabled? && + pushs = extheaders["plum.serverpush"] authority = reqheaders.find { |k, v| k == ":authority" }[1] scheme = reqheaders.find { |k, v| k == ":scheme" }[1] diff --git a/lib/plum/rack/server.rb b/lib/plum/rack/server.rb index 0f8338c..b64e095 100644 --- a/lib/plum/rack/server.rb +++ b/lib/plum/rack/server.rb @@ -2,7 +2,10 @@ module Plum module Rack class Server + attr_reader :config + def initialize(app, config) + @config = config @state = :null @app = config[:debug] ? ::Rack::CommonLogger.new(app) : app @logger = Logger.new(config[:log] || $stdout).tap { |l| @@ -47,7 +50,7 @@ module Plum sock = sock.accept if sock.respond_to?(:accept) plum = svr.plum(sock) - con = Connection.new(@app, plum, @logger) + con = Connection.new(@app, plum, @logger, server_push: @config[:server_push]) con.run rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINVAL => e # closed sock.close if sock |