class HTTPX::Transcoder::GRPCEncoding::Deflater

  1. lib/httpx/plugins/grpc/grpc_encoding.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. bytesize
  2. content_type
  3. read

Attributes

Public Class methods

new(body, compressed:)
[show source]
   # File lib/httpx/plugins/grpc/grpc_encoding.rb
11 def initialize(body, compressed:)
12   @content_type = body.content_type
13   @body = BodyReader.new(body)
14   @compressed = compressed
15 end

Public Instance methods

bytesize()
[show source]
   # File lib/httpx/plugins/grpc/grpc_encoding.rb
17 def bytesize
18   return @body.bytesize if @body.respond_to?(:bytesize)
19 
20   Float::INFINITY
21 end
read(length = nil, outbuf = nil)
[show source]
   # File lib/httpx/plugins/grpc/grpc_encoding.rb
23 def read(length = nil, outbuf = nil)
24   buf = @body.read(length, outbuf)
25 
26   return unless buf
27 
28   compressed_flag = @compressed ? 1 : 0
29 
30   buf = outbuf if outbuf
31 
32   buf.prepend([compressed_flag, buf.bytesize].pack("CL>"))
33   buf
34 end