Skip to content

Instantly share code, notes, and snippets.

@simonmichael
Forked from anonymous/gist:5005479
Last active December 14, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonmichael/5005481 to your computer and use it in GitHub Desktop.
Save simonmichael/5005481 to your computer and use it in GitHub Desktop.
http-conduit issues
-- | 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
[3 of 5] Compiling Feed ( Feed.hs, Feed.o )
Feed.hs:183:16:
No instance for (Control.Monad.Trans.Resource.MonadResource IO)
arising from a use of `httpLbs'
Possible fix:
add an instance declaration for
(Control.Monad.Trans.Resource.MonadResource IO)
In a stmt of a 'do' block: rsp <- httpLbs r' manager
In the expression:
do { r <- parseUrl s;
let cachecontrol = cache_control opts
r'
| null cachecontrol = r
| otherwise = ...;
rsp <- httpLbs r' manager;
return $ LB8.unpack $ responseBody rsp }
In a case alternative:
Just _
-> do { r <- parseUrl s;
let cachecontrol = ...
....;
rsp <- httpLbs r' manager;
.... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment