Method: HTTPX::Response::Buffer#to_s

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

#to_sObject

returns the buffered content as a string.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/httpx/response/buffer.rb', line 49

def to_s
  case @buffer
  when StringIO
    begin
      @buffer.string.force_encoding(@encoding)
    rescue ArgumentError
      @buffer.string
    end
  when Tempfile
    rewind
    content = @buffer.read
    begin
      content.force_encoding(@encoding)
    rescue ArgumentError # ex: unknown encoding name - utf
      content
    end
  end
end