[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Iterating over POST keys and values
From: |
Simon Newton |
Subject: |
Re: [libmicrohttpd] Iterating over POST keys and values |
Date: |
Wed, 25 Jul 2012 13:11:27 -0700 |
On Tue, Jul 24, 2012 at 11:15 PM, address@hidden
<address@hidden> wrote:
> Hey all,
>
> I'm a new-ish user of libmicrohttpd and have over the past couple weeks
> ventured for the first time into using POST data.
>
> I'm implementing a server that has thusfar only used GET and we were getting
> all of the key-value pairs using MHD_get_connection_values. Something like:
>
> typedef std::pair<std::string, std::string> TArg;
> typedef std::vector<TArg> TArgs;
>
> static int _get_params (void *cls, enum MHD_ValueKind , const char *key,
> const char *data)
> {
> TArgs* args = (TArgs*)cls;
> TArg arg(key, (data ? data : ""));
> args->push_back (arg);
> return MHD_YES;
> }
>
> and then in the answer callback passed to MHD_start_daemon, there's a line:
>
> TArgs args;
> MHD_get_connection_values (connection, t, _get_params, &args);
>
> Ensuring that _get_params will be iterated over to get all the values and
> stock them in TArgs.
>
> All of this works well in GET and we'd like to set up the same thing in
> POST. However, reading over POST, I don't see a clean way to iterate over
> keys and values in the same manner. I've followed through the tutorials and
> can create postprocessors for single keys that handle uploads of large
> chunks of data, but I can't figure out how to do the above sort of
> manipulation. Does anyone have any intuition about how the above could be
> done via POST?
http://code.google.com/p/open-lighting/source/browse/olad/HttpServer.cpp
That accumulates the key: value pairs in a map (since we don't care
about multiple keys in this case).
Simon
>
> Cheers,
> Mike