comparison lib/ur/top.ur @ 1787:69daa6d70299

Top.postFields
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Jul 2012 15:16:57 -0400
parents 818d4097e2ed
children a3435112b83e
comparison
equal deleted inserted replaced
1786:d794149b3713 1787:69daa6d70299
391 391
392 fun mkRead' [t ::: Type] (f : string -> option t) (name : string) : read t = 392 fun mkRead' [t ::: Type] (f : string -> option t) (name : string) : read t =
393 mkRead (fn s => case f s of 393 mkRead (fn s => case f s of
394 None => error <xml>Invalid {txt name}: {txt s}</xml> 394 None => error <xml>Invalid {txt name}: {txt s}</xml>
395 | Some v => v) f 395 | Some v => v) f
396
397 fun postFields pb =
398 let
399 fun postFields' s =
400 case firstFormField s of
401 None => []
402 | Some f => (fieldName f, fieldValue f) :: postFields' (remainingFields f)
403 in
404 case postType pb of
405 "application/x-www-form-urlencoded" => postFields' (postData pb)
406 | _ => error <xml>Tried to get POST fields, but MIME type is not "application/x-www-form-urlencoded"</xml>
407 end