mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
using the pushed response header from nghttp2.org to test whether asset was pushed
This commit is contained in:
parent
767637f15f
commit
761ecb800d
@ -33,6 +33,10 @@ module HTTPX
|
||||
end
|
||||
alias :plugins :plugin
|
||||
|
||||
def with(options)
|
||||
branch(default_options.merge(options))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_options
|
||||
|
@ -10,14 +10,18 @@ module ResponseHelpers
|
||||
%w(header param).each do |meth|
|
||||
class_eval <<-DEFINE, __FILE__, __LINE__ + 1
|
||||
def verify_#{meth}(#{meth}s, key, expect)
|
||||
assert #{meth}s.key?(key), "#{meth}s don't contain the given key (" + key + ")"
|
||||
assert #{meth}s.key?(key), "#{meth}s don't contain the given key (\#{key})"
|
||||
value = #{meth}s[key]
|
||||
if value.respond_to?(:start_with?)
|
||||
assert value.start_with?(expect), "#{meth} assertion failed: " + key + "=" + value + " (expected: " + expect + ")"
|
||||
assert value.start_with?(expect), "#{meth} assertion failed: \#{key}=\#{value} (expected: \#{expect}})"
|
||||
else
|
||||
assert value == expect, "#{meth} assertion failed: " + key + "=" + value.to_s + " (expected: " + expect.to_s + ")"
|
||||
assert value == expect, "#{meth} assertion failed: \#{key}=\#{value.to_s} (expected: \#{expect.to_s})"
|
||||
end
|
||||
end
|
||||
|
||||
def verify_no_#{meth}(#{meth}s, key)
|
||||
assert !#{meth}s.key?(key), "#{meth}s contains the given key (" + key + "=\#{#{meth}s[key]})"
|
||||
end
|
||||
DEFINE
|
||||
end
|
||||
|
||||
|
@ -3,13 +3,22 @@
|
||||
module Requests
|
||||
module Plugins
|
||||
module PushPromise
|
||||
def test_plugin_push_promise_get_all
|
||||
def test_plugin_push_promise_get
|
||||
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)
|
||||
verify_header(css.headers, "x-http2-push", "1")
|
||||
end
|
||||
|
||||
def test_plugin_push_promise_concurrent
|
||||
client = HTTPX.plugin(:push_promise)
|
||||
.with(max_concurrent_requests: 100)
|
||||
html, css = client.get(push_html_uri, push_css_uri)
|
||||
verify_status(html.status, 200)
|
||||
verify_status(css.status, 200)
|
||||
verify_no_header(css.headers, "x-http2-push")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user