Class: HTTPX::Transcoder::GRPCEncoding::Inflater
- Inherits:
-
Object
- Object
- HTTPX::Transcoder::GRPCEncoding::Inflater
- Defined in:
- lib/httpx/plugins/grpc/grpc_encoding.rb,
sig/plugins/grpc/grpc_encoding.rbs
Instance Method Summary collapse
- #call(message, &blk) ⇒ void
- #grpc_encodings ⇒ Array[String]
-
#initialize(response) ⇒ Inflater
constructor
A new instance of Inflater.
Constructor Details
#initialize(response) ⇒ Inflater
Returns a new instance of Inflater.
40 41 42 43 |
# File 'lib/httpx/plugins/grpc/grpc_encoding.rb', line 40 def initialize(response) @response = response @grpc_encodings = nil end |
Instance Method Details
#call(message, &blk) ⇒ void
This method returns an undefined value.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/httpx/plugins/grpc/grpc_encoding.rb', line 45 def call(, &blk) data = "".b until .empty? compressed, size = .unpack("CL>") encoded_data = .byteslice(5..(size + 5 - 1)) if compressed == 1 grpc_encodings.reverse_each do |encoding| decoder = @response.body.class.initialize_inflater_by_encoding(encoding, @response, bytesize: encoded_data.bytesize) encoded_data = decoder.call(encoded_data) blk.call(encoded_data) if blk data << encoded_data end else blk.call(encoded_data) if blk data << encoded_data end = .byteslice((size + 5)..-1) end data end |
#grpc_encodings ⇒ Array[String]
76 77 78 |
# File 'lib/httpx/plugins/grpc/grpc_encoding.rb', line 76 def grpc_encodings @grpc_encodings ||= @response.headers.get("grpc-encoding") end |