Public Class methods
new(response)
[show source]
# File lib/httpx/plugins/grpc/grpc_encoding.rb 38 def initialize(response) 39 @response = response 40 @grpc_encodings = nil 41 end
Public Instance methods
call(message, &blk)
[show source]
# File lib/httpx/plugins/grpc/grpc_encoding.rb 43 def call(message, &blk) 44 data = "".b 45 46 until message.empty? 47 compressed, size = message.unpack("CL>") 48 49 encoded_data = message.byteslice(5..size + 5 - 1) 50 51 if compressed == 1 52 grpc_encodings.reverse_each do |encoding| 53 decoder = @response.body.class.initialize_inflater_by_encoding(encoding, @response, bytesize: encoded_data.bytesize) 54 encoded_data = decoder.call(encoded_data) 55 56 blk.call(encoded_data) if blk 57 58 data << encoded_data 59 end 60 else 61 blk.call(encoded_data) if blk 62 63 data << encoded_data 64 end 65 66 message = message.byteslice((size + 5)..-1) 67 end 68 69 data 70 end