summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-07-21 15:16:57 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-07-21 15:16:57 -0400
commitefeb64a601c052ed533caee0131befe2c96bb91c (patch)
tree4be6d87576e314c5a2a1ecbaed89913bceca422f /src
parent8ac6c0fe4425753c64fa0ef0a129d33eef36cb5c (diff)
Top.postFields
Diffstat (limited to 'src')
-rw-r--r--src/c/request.c2
-rw-r--r--src/c/urweb.c40
-rw-r--r--src/settings.sml6
3 files changed, 46 insertions, 2 deletions
diff --git a/src/c/request.c b/src/c/request.c
index a697ba44..b23c251f 100644
--- a/src/c/request.c
+++ b/src/c/request.c
@@ -294,7 +294,7 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
boundary[0] = '-';
boundary[1] = '-';
boundary_len = strlen(boundary);
- } else if (clen_s && strcasecmp(clen_s, "application/x-www-form-urlencoded")) {
+ } else if (clen_s) {
uw_Basis_postBody pb = {clen_s, body};
uw_postBody(ctx, pb);
}
diff --git a/src/c/urweb.c b/src/c/urweb.c
index d0b6987c..0ccc418a 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -4086,3 +4086,43 @@ uw_Basis_string uw_Basis_property(uw_context ctx, uw_Basis_string s) {
return s;
}
+
+uw_Basis_string uw_Basis_fieldName(uw_context ctx, uw_Basis_postField f) {
+ return f.name;
+}
+
+uw_Basis_string uw_Basis_fieldValue(uw_context ctx, uw_Basis_postField f) {
+ return f.value;
+}
+
+uw_Basis_string uw_Basis_remainingFields(uw_context ctx, uw_Basis_postField f) {
+ return f.remaining;
+}
+
+uw_Basis_postField *uw_Basis_firstFormField(uw_context ctx, uw_Basis_string s) {
+ char *amp, *eq, *unurl, *copy;
+ uw_Basis_postField *f;
+
+ if (s[0] == 0)
+ return NULL;
+
+ amp = strchr(s, '&');
+ copy = uw_malloc(ctx, amp ? amp - s + 1 : strlen(s) + 1);
+ if (amp) {
+ strncpy(copy, s, amp - s);
+ copy[amp - s] = 0;
+ } else
+ strcpy(copy, s);
+
+ eq = strchr(copy, '=');
+ if (eq)
+ *eq++ = 0;
+
+ f = uw_malloc(ctx, sizeof(uw_Basis_postField));
+ unurl = copy;
+ f->name = uw_Basis_unurlifyString(ctx, &unurl);
+ f->value = eq ? (unurl = eq, uw_Basis_unurlifyString(ctx, &unurl)) : "";
+ f->remaining = amp ? amp+1 : "";
+
+ return f;
+}
diff --git a/src/settings.sml b/src/settings.sml
index dcaf392d..9359337d 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -218,7 +218,11 @@ val serverBase = basis ["requestHeader",
"nextval",
"setval",
"channel",
- "send"]
+ "send",
+ "fieldName",
+ "fieldValue",
+ "remainingFields",
+ "firstFormField"]
val server = ref serverBase
fun setServerOnly ls = server := S.addList (serverBase, ls)
fun isServerOnly x = S.member (!server, x)