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
108 def initialize(body, deflater)
109   @body = body.respond_to?(:read) ? body : StringIO.new(body.to_s)
110   @buffer = StringIO.new("".b, File::RDWR)
111   @deflater = deflater
112 end

Public Instance methods

bytesize ()
[show source]
    # File lib/httpx/plugins/compression.rb
124 def bytesize
125   deflate
126   @buffer.size
127 end
close ()
[show source]
    # File lib/httpx/plugins/compression.rb
135 def close
136   @buffer.close
137   @body.close
138 end
each (&blk)
[show source]
    # File lib/httpx/plugins/compression.rb
114 def each(&blk)
115   return enum_for(__method__) unless block_given?
116 
117   unless @buffer.size.zero?
118     @buffer.rewind
119     return @buffer.each(&blk)
120   end
121   deflate(&blk)
122 end
to_s ()
[show source]
    # File lib/httpx/plugins/compression.rb
129 def to_s
130   deflate
131   @buffer.rewind
132   @buffer.read
133 end