on master help sign in
Support for non-files in multipart requests.

There was a bug which required each piece in a multipart to have a content-type associated with it, thereby ignoring non-file parameters.

commitbf69aaadf805a1db63e70d5ab3d1f2cece523f8c authorMichael Snoyman <michael@snoyman.com> dateFri 9 Jul 2010, 10:19 (16 years ago) parente9e62f3
2 files changed+5−4
Network/Wai/Parse.hs+4−3 wai-extra.cabal+1−1
Network/Wai/Parse.hs+4−3
@@ -244,6 +244,7 @@ parsePieces sink bound src = do
244244 res <- takeLine src
245245 src' <- case res of
246246 Nothing -> return (S.empty, Nothing)
247+ -- The _bs here should only contain boundary information
247248 Just (_bs, src') -> return src'
248249 res' <- takeLines src'
249250 case res' of
@@ -252,14 +253,14 @@ parsePieces sink bound src = do
252253 let ls' = map parsePair ls
253254 let x = do
254255 cd <- lookup contDisp ls'
255− ct <- lookup contType ls'
256+ let ct = lookup contType ls'
256257 let attrs = parseAttrs cd
257258 let nameBS = S8.pack "name"
258259 name <- lookup nameBS attrs
259260 let fnBS = S8.pack "filename"
260261 return (ct, name, lookup fnBS attrs)
261262 case x of
262− Just (ct, name, Just filename) -> do
263+ Just (Just ct, name, Just filename) -> do
263264 seed <- sinkInit sink
264265 (seed', wasFound, msrc''') <-
265266 sinkTillBound bound src'' (sinkAppend sink) seed
@@ -283,7 +284,7 @@ parsePieces sink bound src = do
283284 then parsePieces sink bound msrc'''
284285 else return ([], [])
285286 return (x' : xs, ys)
286− Nothing -> do
287+ _ -> do
287288 -- ignore this part
288289 let seed = ()
289290 iter () _ = return ()
wai-extra.cabal+1−1
@@ -1,5 +1,5 @@
11Name: wai-extra
2−Version: 0.1.3
2+Version: 0.1.3.1
33Synopsis: Provides some basic WAI handlers and middleware.
44Description: The goal here is to provide common features without many dependencies.
55License: BSD3