libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] MHD_ContentReaderCallback empty content


From: Christian Grothoff
Subject: Re: [libmicrohttpd] MHD_ContentReaderCallback empty content
Date: Sun, 06 Jan 2013 21:13:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11

On 01/06/2013 08:57 PM, Sascha Swiercy wrote:
> I'd like to know if it is possible to use
> MHD_create_response_from_callback even if the content length is 0. I
> tried to pass 0 as first argument to MHD_create_response_from_callback
> and also returned 0 from the callback, but this made the library to
> invoke the callback function in an infinite loop. The documentation
> also states this behavior, but I was curious if there is a way to use
> MHD_create_response_from_callback even for an empty response body. If
> not, then I'd suggest to make MHD_create_response_from_callback fail
> in some way if 0 is passed as size. Thanks for your help.
> 
> -Sascha
> 

Dear Sascha,

Thanks for the report, this looks like an interesting corner case we
didn't handle nicely.  The attached patch (also in SVN 25703) should
address it.  Basically, if the message size is zero, your response
callback is unable to communicate the difference between "wait for a
response later (return 0)" and "here is the non-existing reply (return
0)".  The patch fixes it by checking if the body size is zero and then
simply never calling the callback in the first place.

Please let me know if the patch doesn't solve the issue.

Happy hacking!

Christian

Attachment: 0-response.diff
Description: Text Data


reply via email to

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