Question

I'm trying to POST a multipart form request to an internal website which should reply with an XML response. Using another simple script I have in Python with the requests library, everything works fine, however, using http-conduit I keep receiving an exception ExpectedBlankAfter100Continue.

If I replace the internal url with "https://httpbin.org/post", I also receive a reply back without issue.

Is there something I'm doing wrong? It seems like either a bug in the library or the site is not behaving as expected. If the latter is the case, is there an option for me to disable this check in http-conduit?

Sample code:

{-# LANGUAGE OverloadedStrings #-}

import Network
import Network.HTTP.Conduit
import Network.HTTP.Client.MultipartFormData
import qualified Data.ByteString.Lazy.Char8 as BL
import Data.Maybe (fromJust)
import System.Environment (getArgs)
import Control.Monad.IO.Class

main = do
    [x] <- getArgs
    --let url = "https://url.net/api.asp"
    let url = "https://httpbin.org/post"
    withSocketsDo $ withManager $ \m -> do
        r <- flip httpLbs m =<< (formDataBody (request $ BL.pack x) $ fromJust $ parseUrl url)
        liftIO $ BL.putStrLn $ responseBody r

request :: BL.ByteString -> [Part]
request x = <code removed>
Était-ce utile?

La solution

This sounds like the server is returning a malformed 100-continue response. But there's not enough information here to properly debug this, it's probably better to handle this in a Github issue.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top