Module: HTTPX::Plugins::Expect::InstanceMethods

Defined in:
lib/httpx/plugins/expect.rb

Instance Method Summary collapse

Instance Method Details

#fetch_response(request, selector, options) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/httpx/plugins/expect.rb', line 128

def fetch_response(request, selector, options)
  response = super

  return unless response

  if response.is_a?(Response) && response.status == 417 && request.headers.key?("expect")
    response.close
    request.headers.delete("expect")
    request.transition(:idle)
    send_request(request, selector, options)

    # recalling itself, in case an error was triggered by the above, and we can
    # verify retriability again.
    return fetch_response(request, selector, options)
  end

  response
end