handle http(s)://

This commit is contained in:
Filip Gralinski 2018-06-02 23:27:49 +02:00
parent 57ee8a1296
commit ffb24509d7
2 changed files with 10 additions and 10 deletions

View File

@ -71,15 +71,15 @@ getSmartSourceSpec defaultDirectory defaultFile spec
smartSource (FilePathSpec filePath) = sourceFile filePath
smartSource Stdin = sourceHandle stdin
smartSource NoSource = error $ "should not be here"
smartSource (Http url) = httpSource url
smartSource (Https url) = httpSource url
-- httpSource :: MonadResource m => String -> ConduitM () S.ByteString m ()
-- httpSource url = do
-- request <- liftIO $ parseRequest url
-- manager <- liftIO $ newManager tlsManagerSettings
-- response <- lift $ http request manager
-- (httpsource, finalizer) <- lift $ unwrapResumable (responseBody response)
-- httpsource
-- lift finalizer
httpSource :: MonadResource m => String -> ConduitM () S.ByteString m ()
httpSource url = do
request <- liftIO $ parseRequest url
manager <- liftIO $ newManager tlsManagerSettings
response <- lift $ http request manager
responseBody response
checkRefFormat :: String -> Bool
checkRefFormat ref =

View File

@ -309,8 +309,8 @@ main = hspec $ do
getSmartSourceSpec "foo" "in.tsv" "https://gonito.net" `shouldReturn` (Right $ Https "https://gonito.net")
it "sources are accessed" $ do
readFromSmartSource "baz" "out.tsv" "test/files/foo.txt" `shouldReturn` ["foo\n"]
-- readFromSmartSource [] Nothing "https://httpbin.org/robots.txt" `shouldReturn`
-- ["User-agent: *\nDisallow: /deny\n"]
readFromSmartSource "" "" "https://httpbin.org/robots.txt" `shouldReturn`
["User-agent: *\nDisallow: /deny\n"]
readFromSmartSource :: FilePath -> FilePath -> String -> IO [String]
readFromSmartSource defaultDir defaultFile specS = do