getFinalRedirectTarget :: String -> IO String
getFinalRedirectTarget url = do
    curl <- initialize
    setopts curl [ CurlURL url
                 , CurlUserAgent userAgent
                 , CurlWriteFunction dummyWriteFunction
                 , CurlFollowLocation True
                 ]
    perform curl
    getEffectiveUrl curl

-- | Accesses the given URL. If the resulting HTTP status code is 301, 302, or
-- 303, the URL is re-requested and the HTTP redirects are followed as far as
-- they go. The returned 'CurlResult' includes the HTTP status code from the
-- original request and the final target of redirects, if applicable.
--
-- If Curl encounters some kind of problem and gives a status code of 0 then
-- this function will retry that URL once. (This can happen if the server thinks
-- we're a malicious bot and unexpectedly terminates the connection.)
getFinalRedirectTarget :: String -> IO String
getFinalRedirectTarget url = do
    curl <- initialize
    setopts curl [ CurlURL url
                 , CurlUserAgent userAgent
                 , CurlWriteFunction dummyWriteFunction
                 , CurlFollowLocation True
                 ]
    perform curl
    getEffectiveUrl curl

-- | Accesses the given URL. If the resulting HTTP status code is 301, 302, or
-- 303, the URL is re-requested and the HTTP redirects are followed as far as
-- they go. The returned 'CurlResult' includes the HTTP status code from the
-- original request and the final target of redirects, if applicable.
--
-- If Curl encounters some kind of problem and gives a status code of 0 then
-- this function will retry that URL once. (This can happen if the server thinks
-- we're a malicious bot and unexpectedly terminates the connection.)
getFinalRedirectTarget url = do
    curl <- initialize
    setopts curl [ CurlURL url
                 , CurlUserAgent userAgent
                 , CurlWriteFunction dummyWriteFunction
                 , CurlFollowLocation True
                 ]
    perform curl
    getEffectiveUrl curl

-- | Accesses the given URL. If the resulting HTTP status code is 301, 302, or
-- 303, the URL is re-requested and the HTTP redirects are followed as far as
-- they go. The returned 'CurlResult' includes the HTTP status code from the
-- original request and the final target of redirects, if applicable.
--
-- If Curl encounters some kind of problem and gives a status code of 0 then
-- this function will retry that URL once. (This can happen if the server thinks
-- we're a malicious bot and unexpectedly terminates the connection.)