[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] bug + question



Hi all. I've found that evhttp_parse_query_str only works if the query
string is of the form foo=bar&baz=quux. If we have a query string of
the form foo=bar&baz (no value for the last key), it fails. I consider
this a bug, because you have all the other valid parameters in there,
and it can just set NULL for the value of the baz parameter. I believe
the behavior of evhttp_parse_query() is different (correct). I had
used evhttp_parse_query() until now, and switched to
evhttp_parse_query_str() and discovered this bug.

Second, I have a question - does one need to evhttp_uri_free() the
returned pointer from evhttp_request_get_evhttp_uri()? It crashes if I
do free it, so i'd like to make sure it's correct to not free it (no
memory leaks).

Also, is the evkeyvalq usage in this example correct? Note that it
includes the issues described above:

static void httpcb(struct evhttp_request *req, void *arg) {
    evkeyvalq query; // is it meant to be used in this way?
    evhttp_parse_query_str(evhttp_uri_get_query(evhttp_request_get_evhttp_uri(req)),
&query);
    const char *val;
    if((val = evhttp_find_header(&query, "command"))) {
        ...
    }
}

Thanks
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.