jnunemaker/httparty — pull request #317 by madumlao (2014-07-31 13:10:45+00:00)
Title: Follow 303 redirects with GET unless specifically asked to resend.

When an HTTP 3xx response (redirection) is given, httparty by default follows the redirection using a GET request. If the maintain_method_across_redirects is specified, however, httparty will follow the redirection using the same method that was issued for the original request. This will cause httparty to retry the request at the target URL and makes sense for idempotent server methods.

For non-idempotent methods, however, retrying the request at the target URL may result in duplicated data, resulting in issue #316. For this reason, HTTP provides the 303 redirect response, which indicates that the client should attempt to access the target URL using a GET request, rather than retrying the request at the target URL.

This changeset modifies the redirect logic so that 303 responses will normally cause resending to try a GET request, unless specifically forced by adding resend_on_redirect is set to true.

Examples:
-------

This class will resend a request on any redirect, even 303 responses:

class Foo
include HTTParty
base_uri 'http://myapi.example.com'
maintain_method_on_redirects
resend_on_redirect
end

This class will resend requests on all 3xx responses except 303's. 303 responses will be followed with a GET.

class Bar
include HTTParty
base_uri 'http://myapi.example.com'
maintain_method_on_redirects
end

reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html