]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/http.c
How about that ... we're now correctly handling the reply-references and carrying...
[citadel.git] / webcit-ng / http.c
index 29a1fba6d5070e9ec4218d4fa5c6ae153c7e40c0..8daa52afa6985e6a05765307772c095513433da2 100644 (file)
@@ -173,6 +173,7 @@ void perform_one_http_transaction(struct client_handle *ch) {
                                kv.key = strdup(tok);
                                kv.val = strdup(eq);
                                array_append(h.request_parms, &kv);
+                               syslog(LOG_DEBUG, "\033[1m\033[33m| %s = %s\033[0m", kv.key, kv.val);
                        }
                }
        }
@@ -302,3 +303,20 @@ char *header_val(struct http_transaction *h, char *requested_header) {
        }
        return (NULL);
 }
+
+
+// Utility function to fetch a specific URL parameter from a completely read-in request.
+// Returns the value of the requested parameter, or NULL if the specified parameter was not sent.
+// The caller does NOT own the memory of the returned pointer, but can count on the pointer
+// to still be valid through the end of the transaction.
+char *get_url_param(struct http_transaction *h, char *requested_param) {
+       struct keyval *kv;
+       int i;
+       for (i=0; i<array_len(h->request_parms); ++i) {
+               kv = array_get_element_at(h->request_parms, i);
+               if (!strcasecmp(kv->key, requested_param)) {
+                       return (kv->val);
+               }
+       }
+       return (NULL);
+}