My users submit urls (to mixes on mixcloud.com) and my app uses them to perform web requests.
A good url returns a 200 status code:
rest-client follows the redirections for GET and HEAD requests without any additional configuration. It works very nice.
- for result codes between 200 and 207, a RestClient::Response will be returned
- for result codes 301, 302 or 307, the redirection will be followed if the request is a GET or a HEAD
- for result code 303, the redirection will be followed and the request transformed into a GET
example of usage:
require 'rest-client'
RestClient.get 'http://example.com/resource'
The rest-client README also gives an example of following redirects with POST requests:
begin
RestClient.post('http://example.com/redirect', 'body')
rescue RestClient::MovedPermanently,
RestClient::Found,
RestClient::TemporaryRedirect => err
err.response.follow_redirection
end