class HTTPX::Plugins::Compression::Encoder

  1. lib/httpx/plugins/compression.rb
Superclass: Object

Methods

Public Class

  1. new

Public Instance

  1. bytesize
  2. close
  3. each
  4. to_s

Public Class methods

new (body, deflater)
[show source]
    # File lib/httpx/plugins/compression.rb
104 def initialize(body, deflater)
105   @body = body.respond_to?(:read) ? body : StringIO.new(body.to_s)
106   @buffer = StringIO.new("".b, File::RDWR)
107   @deflater = deflater
108 end

Public Instance methods

bytesize ()
[show source]
    # File lib/httpx/plugins/compression.rb
120 def bytesize
121   deflate
122   @buffer.size
123 end
close ()
[show source]
    # File lib/httpx/plugins/compression.rb
131 def close
132   @buffer.close
133   @body.close
134 end
each (&blk)
[show source]
    # File lib/httpx/plugins/compression.rb
110 def each(&blk)
111   return enum_for(__method__) unless block_given?
112 
113   unless @buffer.size.zero?
114     @buffer.rewind
115     return @buffer.each(&blk)
116   end
117   deflate(&blk)
118 end
to_s ()
[show source]
    # File lib/httpx/plugins/compression.rb
125 def to_s
126   deflate
127   @buffer.rewind
128   @buffer.read
129 end