diff 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
line wrap: on
line diff
--- a/lib/ur/top.ur	Sat Jul 21 13:55:35 2012 -0400
+++ b/lib/ur/top.ur	Sat Jul 21 15:16:57 2012 -0400
@@ -393,3 +393,15 @@
     mkRead (fn s => case f s of
                         None => error <xml>Invalid {txt name}: {txt s}</xml>
                       | Some v => v) f
+
+fun postFields pb =
+    let
+        fun postFields' s =
+            case firstFormField s of
+                None => []
+              | Some f => (fieldName f, fieldValue f) :: postFields' (remainingFields f)
+    in
+        case postType pb of
+            "application/x-www-form-urlencoded" => postFields' (postData pb)
+          | _ => error <xml>Tried to get POST fields, but MIME type is not "application/x-www-form-urlencoded"</xml>
+    end