[web-devel] wai-test, does it accept multipart/form-data too?

Nubis nubis at woobiz.com.ar
Mon Jan 2 16:31:48 CET 2012

Hi guys, I'm building a yesod testing tool, in part building on top of
wai-test for interacting with the yesod application. But I'm noticing
that sending multipart/form-data requests using wai-test is not
working. url-encoded requests are working as expected, both get and
post. The symptom I'm seeing is that both the result of
lookupPostParams and lookupFiles for the parameter I'm sending return
empty lists. I dug through wai, wai-extra, and yesod handler code and
as it seems, yesod's code should be taking care of using
wai-extra.parse  to get the FileInfo's.

I don't want to bother you with the details yet, but I just wanted to
know if this is a 'known limitation' of wai-test. More specifically,
given this function:

srequest :: SRequest -> Session SResponse
srequest (SRequest req bod) = do
    app <- ask
    res <- liftIO $ run_ $ enumList 4 (L.toChunks bod) $$ app req
    sres <- liftIO $ runResponse res
    return sres

If 'app' is the wai Application (gotten through toWaiApp), and that
app works well with url-encoded. And bod is a lazy char8 bytestring
containing a well formed multi-part request body, then my yesod
handler should end up having the file data available? right?

Also, are there any tests you recommend I do to figure what's going wrong?

I can alternatively just publish this testing library/framework now
with the broken functionality so you can fork it from github.


----nubis :)

More information about the web-devel mailing list