Method: HTTPX::Connection::HTTP1#on_headers

Defined in:
lib/httpx/connection/http1.rb

#on_headers(h) ⇒ Object

[View source]

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/httpx/connection/http1.rb', line 110

def on_headers(h)
  @request = @requests.first

  return if @request.response

  log(level: 2) { "headers received" }
  headers = @request.options.headers_class.new(h)
  response = @request.options.response_class.new(@request,
                                                 @parser.status_code,
                                                 @parser.http_version.join("."),
                                                 headers)
  log(color: :yellow) { "-> HEADLINE: #{response.status} HTTP/#{@parser.http_version.join(".")}" }
  log(color: :yellow) { response.headers.each.map { |f, v| "-> HEADER: #{f}: #{v}" }.join("\n") }

  @request.response = response
  on_complete if response.finished?
end