fetchURL :: String -> IO (Maybe (String, String))
fetchURL url = do
  flip catchIO_ (return Nothing) $ do
     r <- browse $ do
           setOutHandler (const (return ()))
           setAllowRedirects True
           liftM snd . request . getRequest $ url
     let content_type = lookupHeader HdrContentType (getHeaders r)
     content <- liftM (Just . toStr . encode . toBS) . getResponseBody $ Right r
     return $ liftM2 (,) content_type content
  where
fetchURL :: String -> IO (Maybe (String, String))
fetchURL url = do
  flip catchIO_ (return Nothing) $ do
     r <- browse $ do
           setOutHandler (const (return ()))
           setAllowRedirects True
           liftM snd . request . getRequest $ url
     let content_type = lookupHeader HdrContentType (getHeaders r)
     content <- liftM (Just . toStr . encode . toBS) . getResponseBody $ Right r
     return $ liftM2 (,) content_type content
  where
fetchURL url = do
  flip catchIO_ (return Nothing) $ do
     r <- browse $ do
           setOutHandler (const (return ()))
           setAllowRedirects True
           liftM snd . request . getRequest $ url
     let content_type = lookupHeader HdrContentType (getHeaders r)
     content <- liftM (Just . toStr . encode . toBS) . getResponseBody $ Right r
     return $ liftM2 (,) content_type content
  where