[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] MHD_OPTION_URI_LOG_CALLBACK function is passed empty
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] MHD_OPTION_URI_LOG_CALLBACK function is passed empty URI string: |
Date: |
Wed, 28 May 2014 08:02:22 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 |
On 05/28/2014 03:20 AM, Nader Zeid wrote:
> I can't think of any reason why this won't work. I have the following
> function:
>
>
>
> void * MicroHttpdServer::log(void * cls, const char * uri) {
> Request *request(new Request());
> printf("\nURI: %s\n", uri);
> return request;
> }
>
>
>
> Given as the value of the MHD_OPTION_URI_LOG_CALLBACK option:
>
>
>
> MHD_Daemon *daemon;
> daemon = MHD_start_daemon(
> MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv6,
> MicroHttpdServer::port,
> NULL, // &MicroHttpdServer::authorize
> NULL,
> &MicroHttpdServer::handle,
> NULL,
> MHD_OPTION_THREAD_POOL_SIZE,
> MicroHttpdServer::amount,
> MHD_OPTION_URI_LOG_CALLBACK,
> &MicroHttpdServer::log,
> MHD_OPTION_END
> );
A first bug here is that you need to add an extra 'NULL' argument
after &MicroHttpdServer::log for the 'cls'. Right now, the behavior
is undefined.
Next, you might need to avoid the C++-ism of "MicroHttpdServer::log"
as there is no "self" pointer passed from C, which might effectively
shift your arguments by one. So try with a plain old C function ;-)
Happy hacking!
Christian