libmicrohttpd
[Top][All Lists]
Advanced

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

[libmicrohttpd] Re: libmicrohttpd question


From: Christian Grothoff
Subject: [libmicrohttpd] Re: libmicrohttpd question
Date: Sun, 14 Nov 2010 21:47:08 +0100
User-agent: KMail/1.13.2 (Linux/2.6.32-25-generic; KDE/4.4.2; i686; ; )

Well, this is not something a well-behaved HTTP server should ever do, so I 
think the solution with the footers is cleaner (and we should probably limit 
the API to "legal" HTTP behavior --- after all, if the response construction 
could realistically fail, the developer should take care of this case in a 
nice way).

My 2 cents

Christian

On Sunday, November 14, 2010 09:07:08 pm Jared Cantwell wrote:
> Thanks Christian!
> 
> I think this will help a lot.  Would it make sense to have the ability to
> prematurely close the connection with some error code (i.e. by returning
> -2)?  This is similar to what the try_ready_normal_body() does.  I would
> imagine that any normal client would interpret this as a failed request
> since they would have never received the trailing '0\n\r'.
> 
> ~Jared
> 
> On Sun, Nov 14, 2010 at 2:49 PM, Christian Grothoff
> 
> <address@hidden>wrote:
> > Dear Jared,
> > 
> > I was just about to fire back a response saying: "just add a footer", but
> > then
> > I decided to look for the API for that and I found that -- while 99% of
> > the support for this is there -- a tiny function to do so was missing
> > from the API.
> > 
> > So I'm happy to introduce: "MHD_add_response_footer"; the only difference
> > to
> > 'MHD_add_response_header' being that the 'kind' is set to
> > MHD_FOOTER_KIND. The
> > new API is in SVN 13683.
> > 
> > This helps you in that you simply add a footer that signals your client
> > software that some kind of error happened; doing so inside of the
> > response callback while also returning "-1" should do the trick.
> > 
> > In fact, the recommended approach would actually be to always add a
> > cryptographic checksum (MD5, SHA-1) as a footer.  That way, your clients
> > will
> > also be better at detecting other transmission errors in your gigabytes
> > of data.  This is the best approach, and certainly also how HTTP
> > intended footers
> > to be used.
> > 
> > Naturally, this only works if you can teach your HTTP client to respect
> > footers.  If you cannot do that, I don't have a good answer for you.
> > 
> > Happy hacking,
> > 
> > Christian
> > 
> > On Sunday, November 14, 2010 06:00:37 pm Jared Cantwell wrote:
> > > Hi Christian,
> > > 
> > > Thanks for a great piece of software-- it has helped me tremendously to
> > > quickly implement a key feature for us.  I have a question about
> > > chunked uploads that I was hoping you could help me with.  According
> > > to the documentation (and my reading of the code), when using
> > > MHD_ContentReaderCallback to return chunks of data (i.e. in response to
> > > a GET request), there doesn't seem to be a way to indicate that the
> > > chunked response failed.  Returning 0 will try again, -1 will assume
> > > the transfer completed successfully.  Is there a way to indicate to
> > > MHD that a chunked response failed?  The reason I ask is that we are
> > > transferring files on
> > 
> > the
> > 
> > > order of 10s of GBs, and we're getting this data from throughout our
> > > cluster.  Midway through the transfer, anything could happen, and it
> > 
> > would
> > 
> > > be nice to just prematurely close the connection to signal failure
> > 
> > (instead
> > 
> > > of assuming the end of the chunked data was reached).  Am I missing
> > > something in the interface, or is this just not currently possible?
> > > 
> > > Thanks for any help!!
> > > ~Jared



reply via email to

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