Method: HTTPX::Response::Buffer#initialize_dup

Defined in:
lib/httpx/response/buffer.rb

#initialize_dup(other) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/httpx/response/buffer.rb', line 23

def initialize_dup(other)
  super

  # create new descriptor in READ-ONLY mode
  @buffer =
    case other.buffer
    when StringIO
      StringIO.new(other.buffer.string, mode: File::RDONLY)
    else
      other.buffer.class.new(other.buffer.path, encoding: Encoding::BINARY, mode: File::RDONLY)
    end
end