It is redundant and confusing to pass both the Request args and the
Request when creating a RestClient::Response. Instead, when the response
object needs to read args from the request, access them on the request
object itself. For determining the HTTP method of the request, switch to
calling RestClient::Request#method.
Also normalize the Request#method to be a lowercase string. This makes
handling of redirection and other method-specific functionality actually
work regardless of how the method was provided to Request.new (:get,
'GET', 'get').
Fixes: #461Fixes: #462Fixes: #463
This allows callers to actually determine whether a given request
followed redirection, and if so, what the original responses to each
intermediate request were.
Due to the way the code is organized, the simplest way to achieve this
involves storing the history on request objects as well. This isn't
ideal, but will work for now.
- Remove MaxRedirectsReached, instead raise the normal
ExceptionWithResponse subclasses.
- Handle max_redirects < 0.
- Remove unnecessary arguments to AbstractResponse#return! and
#follow_redirection.
- Generally clean up the redirection code to be somewhat saner.
- Store the request object on responses. We need this in order to be
able to correctly process the cookie jar with the right request URI.
- Fix tests that rely on the old broken Set-Cookie processing code.
- Add test that cookies are not passed across domains on redirect.
* Put unit and integration specs into separate subdirectories
* Consolidate all requires of 'webmock/rspec' into spec_helper.rb
* Use WebMock.{disable!,enable!} for specs calling live server