http-conduit

How can I post FileInfo to a web service using Yesod and Http-Conduit?

半腔热情 提交于 2019-12-07 10:31:28
问题 I am working with the default Yesod scaffolding project. I have created a page that displays a simple form to upload files. (The form will likely be created on the client using Javascript.) For brevity, the form has a single file input: <form method="post" action=@{UploadR}> <input type="file" name="myfile"> <button type="submit"> My objective is to process the form data and then upload the file to a web service. I have no trouble processing the form, my concern is interacting with the web

How can I post FileInfo to a web service using Yesod and Http-Conduit?

风格不统一 提交于 2019-12-05 17:27:04
I am working with the default Yesod scaffolding project. I have created a page that displays a simple form to upload files. (The form will likely be created on the client using Javascript.) For brevity, the form has a single file input: <form method="post" action=@{UploadR}> <input type="file" name="myfile"> <button type="submit"> My objective is to process the form data and then upload the file to a web service. I have no trouble processing the form, my concern is interacting with the web service. For example, given the following Yesod handler: postUploadR :: Handler Html postUploadR = do mgr

connecting http-conduit to xml-conduit

喜欢而已 提交于 2019-12-05 16:49:19
I'm struggling converting a Response from http-conduit to an XML document via xml-conduit. The doPost function takes an XML Document and posts it to the server. The server responds with an XML Document. doPost queryDoc = do runResourceT $ do manager <- liftIO $ newManager def req <- liftIO $ parseUrl hostname let req2 = req { method = H.methodPost , requestHeaders = [(CI.mk $ fromString "Content-Type", fromString "text/xml" :: Ascii) :: Header] , redirectCount = 0 , checkStatus = \_ _ -> Nothing , requestBody = RequestBodyLBS $ (renderLBS def queryDoc) } res <- http req2 manager return $ res

How can I catch a 404 status exception thrown by simpleHttp of Http.Conduit

南笙酒味 提交于 2019-12-05 06:34:45
I'm trying to download all png files contained in an html file. I have trouble catching 404 status exceptions though, instead my program just crashes. Here is some sample to demonstrate: import Network.HTTP.Conduit import qualified Data.ByteString.Lazy as L main = do let badUrl = "http://www.google.com/intl/en_com/images/srpr/WRONG.png" imgData <- (simpleHttp badUrl) `catch` statusExceptionHandler L.writeFile "my.png" imgData statusExceptionHandler :: t -> IO L.ByteString statusExceptionHandler e = (putStrLn "oops") >> (return L.empty) My "oops" message never prints, instead app crashes with:

Disable SSL/TLS certificate validation in Network.HTTP.Conduit

我只是一个虾纸丫 提交于 2019-12-01 17:24:55
I use the http-conduit library version 2.0+ to fetch the contents from a http:// URL: import Network.HTTP.Conduit myurl = ... -- Your URL goes here main = do content <- simpleHttp myurl print $ content When running this program, I get this error: *** Exception: TlsException (HandshakeFailed (Error_Protocol ("certificate rejected: certificate is not allowed to sign another certificate", True,CertificateUnknown))) As can be told from the error message, the problem is the inability of Network.HTTP.Conduit to validate the server certificate appropriately (in this case, there seem to be problems in

Disable SSL/TLS certificate validation in Network.HTTP.Conduit

好久不见. 提交于 2019-12-01 16:54:18
问题 I use the http-conduit library version 2.0+ to fetch the contents from a http:// URL: import Network.HTTP.Conduit myurl = ... -- Your URL goes here main = do content <- simpleHttp myurl print $ content When running this program, I get this error: *** Exception: TlsException (HandshakeFailed (Error_Protocol ("certificate rejected: certificate is not allowed to sign another certificate", True,CertificateUnknown))) As can be told from the error message, the problem is the inability of Network