mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-07 00:05:02 -04:00
fixed brotli, as both the transcoder wasn't loading, and the response wasn't properly decoding
This commit is contained in:
parent
665fd75ea8
commit
5e54fbab2b
@ -5,7 +5,7 @@ module HTTPX
|
|||||||
module Compression
|
module Compression
|
||||||
module Brotli
|
module Brotli
|
||||||
|
|
||||||
def self_load_dependencies(klass, *)
|
def self.load_dependencies(klass, *)
|
||||||
klass.plugin(:compression)
|
klass.plugin(:compression)
|
||||||
require "brotli"
|
require "brotli"
|
||||||
end
|
end
|
||||||
@ -14,15 +14,22 @@ module HTTPX
|
|||||||
Transcoder.register "br", BrotliTranscoder
|
Transcoder.register "br", BrotliTranscoder
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module ResponseBodyMethods
|
||||||
|
def write(chunk)
|
||||||
|
chunk = decompress(chunk)
|
||||||
|
super(chunk)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module BrotliTranscoder
|
module BrotliTranscoder
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def encode(payload)
|
def encode(payload)
|
||||||
Brotli.encode(payload)
|
::Brotli.deflate(payload)
|
||||||
end
|
end
|
||||||
|
|
||||||
def decode(io)
|
def decode(io)
|
||||||
Brotli.decode(io)
|
::Brotli.inflate(io)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module HTTPX
|
|||||||
module Compression
|
module Compression
|
||||||
module GZIP
|
module GZIP
|
||||||
|
|
||||||
def self_load_dependencies(*)
|
def self.load_dependencies(*)
|
||||||
require "zlib"
|
require "zlib"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user