libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] MHD_connection_close API


From: Robert Groenenberg
Subject: Re: [libmicrohttpd] MHD_connection_close API
Date: Tue, 1 Dec 2015 14:31:25 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

Hi Christian,

Let me first clarify the scenario a bit more: the goal is to close the
connection from a client in case the configuration in the application
wrt this client has changed.

I do agree that for a request being processed it would be best to add a
"Connection: Close" header and I probably should do that :)
However, this still leaves the cases where the response has already been
handed to MHD before the need to close the connection arises. The next
opportunity to do so is then when the response is sent (NOTIFY_COMPLETED).
When there are no requests in progress, I'd like to be able to drop the
connection without waiting for it to send a request and then close the
connection.

Cheers,
Robert

On 01-12-15 14:17, Christian Grothoff wrote:
> Hi Robert,
>
> I think I understand you goal, and I think you missed the "trick": if
> you want to force MHD to close a persistent connection after the current
> reply (and the client set keep-alive, it is HTTP/1.1, etc.), what you
> should do is explicitly add a "Connection: Close" header to your
> response.  MHD will detect that you did this, and will then close the
> connection itself.
>
> Alternatively, if you want to hard-close a connection (in violation of
> the protocol) at any time, you just need to return "MHD_NO" from the
> handler.
>
> Please let me know if this somehow doesn't solve your problem (i.e.
> because I didn't understand what you wanted to do).
>
> Happy hacking!
>
> Christian
>
> On 12/01/2015 02:13 PM, Robert Groenenberg wrote:
>> Hi Christian,
>>
>> In my application I want to be able to close a (persistent) connection
>> after completing the current request. For this I had in mind to register
>> a callback for the NOTIFY_COMPLETED option.
>> When the callback is called and my close flag is set, I wanted to call
>> *MHD_connection_close()*.
>> Only glitch is that MHD_connection_close() is not in the external API...
>>
>> Could it be made part of the external API?
>>
>> Kind regards,
>> Robert
>>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]