Class: Net::HTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/party_cc/net/response.rb

Class Method Summary collapse

Class Method Details

.orig_read_newObject



3
# File 'lib/party_cc/net/response.rb', line 3

alias_method :orig_read_new, :read_new

.read_new(sock) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/party_cc/net/response.rb', line 4

def read_new(sock)
  buffer = StringBufferedIO.new

  loop do
    chunk = sock.readuntil("\n", true)
    buffer.write chunk
    break if chunk.sub(/\s+\z/, '').empty?
  end

  buffer.rewind

  httpv, code, msg = read_status_line(buffer)

  res = response_class(code).new(httpv, code, msg)
  each_response_header(buffer) do |k,v|
    res.add_field k, v
  end
  res.instance_variable_set :@raw_headers, buffer.string
  res
end