mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -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 Brotli
|
||||
|
||||
def self_load_dependencies(klass, *)
|
||||
def self.load_dependencies(klass, *)
|
||||
klass.plugin(:compression)
|
||||
require "brotli"
|
||||
end
|
||||
@ -14,15 +14,22 @@ module HTTPX
|
||||
Transcoder.register "br", BrotliTranscoder
|
||||
end
|
||||
|
||||
module ResponseBodyMethods
|
||||
def write(chunk)
|
||||
chunk = decompress(chunk)
|
||||
super(chunk)
|
||||
end
|
||||
end
|
||||
|
||||
module BrotliTranscoder
|
||||
module_function
|
||||
|
||||
def encode(payload)
|
||||
Brotli.encode(payload)
|
||||
::Brotli.deflate(payload)
|
||||
end
|
||||
|
||||
def decode(io)
|
||||
Brotli.decode(io)
|
||||
::Brotli.inflate(io)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ module HTTPX
|
||||
module Compression
|
||||
module GZIP
|
||||
|
||||
def self_load_dependencies(*)
|
||||
def self.load_dependencies(*)
|
||||
require "zlib"
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user