mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
added compression plugin and tests (for now, failing)
This commit is contained in:
parent
6667055e05
commit
b55911277a
9
lib/httpx/plugins/compression.rb
Normal file
9
lib/httpx/plugins/compression.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module HTTPX
|
||||
module Plugins
|
||||
module Compression
|
||||
end
|
||||
register_plugin :compression, Compression
|
||||
end
|
||||
end
|
@ -12,7 +12,9 @@ class HTTP1Test < HTTPTest
|
||||
include Headers
|
||||
include ResponseBody
|
||||
include IO
|
||||
|
||||
|
||||
include Plugins::Compression
|
||||
|
||||
private
|
||||
|
||||
def origin
|
||||
|
@ -11,6 +11,8 @@ class HTTP2Test < HTTPTest
|
||||
include ResponseBody
|
||||
include IO
|
||||
|
||||
include Plugins::Compression
|
||||
|
||||
private
|
||||
|
||||
def origin
|
||||
|
31
test/support/requests/plugins/compression.rb
Normal file
31
test/support/requests/plugins/compression.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Requests
|
||||
module Plugins
|
||||
module Compression
|
||||
def test_plugin_compression_gzip
|
||||
client = HTTPX.plugin(:compression)
|
||||
uri = build_uri("/gzip")
|
||||
response = client.get(uri)
|
||||
verify_status(response.status, 200)
|
||||
verify_body_length(response)
|
||||
body = json_body(response)
|
||||
assert body["gzipped"], "response should be gzipped"
|
||||
end
|
||||
|
||||
def test_plugin_compression_deflate
|
||||
client = HTTPX.plugin(:compression)
|
||||
uri = build_uri("/deflate")
|
||||
response = client.get(uri)
|
||||
verify_status(response.status, 200)
|
||||
verify_body_length(response)
|
||||
assert body["deflated"], "response should be gzipped"
|
||||
end
|
||||
|
||||
def test_plugin_compression_custom
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user