struct GNUNET_REST_RequestHandle
{
+ /**
+ * Map of url parameters
+ */
struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
+
+ /**
+ * Map of headers
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *header_param_map;
+
+ /**
+ * The HTTP method as MHD value (see microhttpd.h)
+ */
const char *method;
+
+ /**
+ * The url as string
+ */
const char *url;
+
+ /**
+ * The POST data
+ */
const char *data;
+
+ /**
+ * The POST data size
+ */
size_t data_size;
};
GNUNET_free (handle);
}
+static int
+header_iterator (void *cls,
+ enum MHD_ValueKind kind,
+ const char *key,
+ const char *value)
+{
+ struct GNUNET_REST_RequestHandle *handle = cls;
+ struct GNUNET_HashCode hkey;
+ char *val;
+
+ GNUNET_CRYPTO_hash (key, strlen (key), &hkey);
+ GNUNET_asprintf (&val, "%s", value);
+ if (GNUNET_OK !=
+ GNUNET_CONTAINER_multihashmap_put (handle->header_param_map,
+ &hkey,
+ val,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not load add header `%s'=%s\n",
+ key, value);
+ }
+ return MHD_YES;
+}
+
static int
url_iterator (void *cls,
rest_conndata_handle->data_size = *upload_data_size;
rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create (16,
GNUNET_NO);
+ rest_conndata_handle->header_param_map = GNUNET_CONTAINER_multihashmap_create (16,
+ GNUNET_NO);
con_handle->data_handle = rest_conndata_handle;
MHD_get_connection_values (con,
MHD_GET_ARGUMENT_KIND,
&url_iterator,
rest_conndata_handle);
+ MHD_get_connection_values (con,
+ MHD_HEADER_KIND,
+ &header_iterator,
+ rest_conndata_handle);
con_handle->state = GN_REST_STATE_PROCESSING;
con_handle->plugin->process_request (rest_conndata_handle,
&plugin_callback,