libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Signalling EOD from MHD_ContentReaderCallback


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Signalling EOD from MHD_ContentReaderCallback
Date: Tue, 27 Oct 2009 07:34:13 +0100
User-agent: KMail/1.11.2 (Linux/2.6.27-15-generic; KDE/4.2.2; i686; ; )

On Monday 26 October 2009 07:53:11 pm Bruce A. Mallett wrote:
> Hi,
>
> I've just started with this library (nice job btw) but have a question ..
>
> How is End Of Data supposed to be signaled by the content provider
> callback once it has exhausted its data stream?  I don't see where the API
> provides for returning this kind of status.  Should it?  Or is there some
> other call that should be made from within the callback to tell the
> library to "quit calling me!".  :)
>
> As it is now returning 0 is an error for the internal select model but
> results in repeated calls in the other models.  Returning -1 closes the
> connection.

You basically have a few choices here.  First, you can specify the length of 
the reply when creating it (if you can, some apps obviously can not do that).  
If you are using a thread-per-connection mode, you should simply block and not 
return until you have the data.  Finally, for all other modes and streams of 
unknown size, "-1" is the right answer: it will finish writing the body (as 
given so far) and close the connection (which is how you signal a client the 
end of the data stream in in this case).

> Also, when the amount of data to be supplied by the content reader is
> provided (first parameter to MHD_create_response_from_callback()) then the
> library knows in advance how much data to expect.  In this instance why
> does the callback continue to get called after all of the data has been
> provided?

No.

> If the amount of data to be provided is unknown in advance (-1 as the
> first parameter to MHD_create_response_from_callback()), how does EOD get
> signaled (I guess that is the same question as what I started with)?

Btw, you should use "MHD_SIZE_UNKNOWN" instead of "-1" in this case. And yes, 
that is the same question ;-).

Best,

Christian




reply via email to

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