Created
February 21, 2013 15:30
-
-
Save anonymous/5005479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Fetch the contents of a uri, which must be an ascii string. | |
-- Redirects, authentication, https: and file: uris are supported. | |
readUri :: Manager -> String -> Opts -> IO String | |
readUri manager s opts = | |
case parseURI' s of | |
Just URI{uriScheme="file:",uriPath=f} -> readFeedFile f | |
Just _ -> do | |
r <- parseUrl s | |
let cachecontrol = cache_control opts | |
r' | null cachecontrol = r | |
| otherwise = r{requestHeaders=(hCacheControl, B8.pack cachecontrol):requestHeaders r} | |
rsp <- httpLbs r' manager | |
return $ LB8.unpack $ responseBody rsp -- $$+- return () ? https://github.com/snoyberg/http-conduit/issues/97#issuecomment-12876868 | |
Nothing -> opterror $ "could not parse URI: " ++ s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment