From: Daniel Gruno Date: Fri, 22 Jun 2012 06:49:12 +0000 (+0000) Subject: xforms X-Git-Tag: 2.4.3~390 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc3cd1c924bf41ecfc7e3cbb8e2a32b5ad42fc9b;p=apache xforms git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1352781 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/developer/modguide.html.en b/docs/manual/developer/modguide.html.en index a6fafcc86a..b6ea8eaa27 100644 --- a/docs/manual/developer/modguide.html.en +++ b/docs/manual/developer/modguide.html.en @@ -565,11 +565,14 @@ POST data is four simple lines:
-apr_table_t *GET;
-apr_array_header_t *POST;
-
-ap_args_to_table(r, &GET);
-ap_parse_form_data(r, NULL, &POST, -1, 8192);
+apr_table_t *GET; 
+apr_array_header_t*POST; 
+
+
+
+ap_args_to_table(r, &GET); 
+
+ap_parse_form_data(r, NULL, &POST, -1, 8192); 
 
@@ -1608,34 +1611,56 @@ or check out the rest of our documentation for further tips.

Some useful snippets of code

-

Retrieve a variable from POST form data

+

Retrieve variables from POST form data

-const char *read_post_value(const apr_array_header_t *fields, const char *key) 
-{
-    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-    int                         i;
-    apr_table_entry_t           *e = 0;
-    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-    e = (apr_table_entry_t *) fields->elts;
-    for(i = 0; i < fields->nelts; i++) {
-        if(!strcmp(e[i].key, key)) return e[i].val;
+typedef struct {
+    const char* key;
+    const char* value;
+} keyValuePair;
+
+keyValuePair* readPost(request_req* r) {
+    apr_array_header_t *pairs = NULL;
+    apr_off_t len;
+    apr_size_t size;
+    int res;
+    int i = 0;
+    char *buffer;
+    keyValuePair* kvp;
+
+    res = ap_parse_form_data(r, NULL, &pairs, -1, HUGE_STRING_LEN);
+    if (res != OK || !pairs) return NULL; /* Return NULL if we failed or if there are is no POST data */
+    kvp = apr_pcalloc(r->pool, sizeof(keyValuePair) * (pairs->nelts + 1));
+    while (pairs && !apr_is_empty_array(pairs)) {
+        ap_form_pair_t *pair = (ap_form_pair_t *) apr_array_pop(pairs);
+        i++;
+        apr_brigade_length(pair->value, 1, &len);
+        size = (apr_size_t) len;
+        buffer = apr_palloc(r->pool, size + 1);
+        apr_brigade_flatten(pair->value, buffer, &size);
+        buffer[len] = 0;
+        kvp[i]->key = apr_pstrdup(r->pool, pair->name);
+        kvp[i]->value = buffer;
     }
-    return 0;
+    return kvp;    
 }
+
 static int example_handler(request_req *r) 
 {
     /*~~~~~~~~~~~~~~~~~~~~~~*/
-    apr_array_header_t *POST;
-    const char         *value;
-    /*~~~~~~~~~~~~~~~~~~~~~~*/
-    ap_parse_form_data(r, NULL, &POST, -1, 8192);
     
-    value = read_post_value(POST, "valueA");
-    if (!value) value = "(undefined)";
-    ap_rprintf(r, "The value of valueA is: %s", value);
+    keyValuePair* formData;
+    /*~~~~~~~~~~~~~~~~~~~~~~*/
+
+    formData = readPost();
+    if (formData) {
+        int i;
+        for (i = 0; formData[i]; i++) {
+            ap_rprintf(r, "%s == %s\n", formData[i]->key, formData[i]->value);
+        }
+    }
     return OK;
 }
 
diff --git a/docs/manual/mod/core.html.fr b/docs/manual/mod/core.html.fr index f0945a1360..0b38f4c924 100644 --- a/docs/manual/mod/core.html.fr +++ b/docs/manual/mod/core.html.fr @@ -31,8 +31,6 @@  ja  |  tr 

-
Cette traduction peut être périmée. Vérifiez la version - anglaise pour les changements récents.
Description:Fonctionnalités de base du serveur HTTP Apache toujours disponibles
Statut:Core
diff --git a/docs/manual/mod/core.xml.meta b/docs/manual/mod/core.xml.meta index b9d96ee4c5..e78755527a 100644 --- a/docs/manual/mod/core.xml.meta +++ b/docs/manual/mod/core.xml.meta @@ -10,7 +10,7 @@ de en es - fr + fr ja tr diff --git a/docs/manual/mod/mod_authn_core.html.en b/docs/manual/mod/mod_authn_core.html.en index b52bd039ac..9790e43dfd 100644 --- a/docs/manual/mod/mod_authn_core.html.en +++ b/docs/manual/mod/mod_authn_core.html.en @@ -116,6 +116,9 @@ Alias /secure /webpages/secure AuthType Basic AuthName "LDAP Protected Place" Require valid-user + # Note that Require ldap-* would not work here, since the + # AuthnProviderAlias does not provide the config to authorization providers + # that are implemented in the same module as the authentication provider. </Directory> diff --git a/docs/manual/mod/mod_authn_core.html.fr b/docs/manual/mod/mod_authn_core.html.fr index 8ea478446f..973f6a674a 100644 --- a/docs/manual/mod/mod_authn_core.html.fr +++ b/docs/manual/mod/mod_authn_core.html.fr @@ -123,6 +123,10 @@ Alias /secure /webpages/secure AuthType Basic AuthName LDAP_Protected Place Require valid-user + # Notez que Require ldap-* ne fonctionnerait pas ici, car + # AuthnProviderAlias ne fournit pas de configuration pour les + # fournisseurs d'autorisation implémentés dans le même module que le + # fournisseur d'authentification. </Directory>