mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-05 00:02:38 -04:00
added draft of push promise plugin
This commit is contained in:
parent
3ffbed8a30
commit
b97405c551
16
lib/httpx/plugins/push_promise.rb
Normal file
16
lib/httpx/plugins/push_promise.rb
Normal file
@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module HTTPX
|
||||
module Plugins
|
||||
module PushPromise
|
||||
PUSH_OPTIONS = { http2_settings: { settings_enable_push: 1 } }
|
||||
|
||||
module InstanceMethods
|
||||
def initialize(opts = {})
|
||||
super(PUSH_OPTIONS.merge(opts))
|
||||
end
|
||||
end
|
||||
end
|
||||
register_plugin(:push_promise, PushPromise)
|
||||
end
|
||||
end
|
@ -16,6 +16,7 @@ class HTTP2Test < HTTPTest
|
||||
include Plugins::FollowRedirects
|
||||
include Plugins::Cookies
|
||||
include Plugins::Compression
|
||||
include Plugins::PushPromise
|
||||
|
||||
private
|
||||
|
||||
|
30
test/support/requests/plugins/push_promise.rb
Normal file
30
test/support/requests/plugins/push_promise.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Requests
|
||||
module Plugins
|
||||
module PushPromise
|
||||
def test_plugin_push_promise_get_all
|
||||
client = HTTPX.plugin(:push_promise)
|
||||
html, css = client.get(push_html_uri, push_css_uri)
|
||||
verify_status(html.status, 200)
|
||||
verify_status(css.status, 200)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def push_origin
|
||||
"https://nghttp2.org"
|
||||
end
|
||||
|
||||
def push_html_uri
|
||||
"#{push_origin}/"
|
||||
end
|
||||
|
||||
def push_css_uri
|
||||
"#{push_origin}/stylesheets/screen.css"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user