libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] MHD_queue_response failing


From: Christian Grothoff
Subject: Re: [libmicrohttpd] MHD_queue_response failing
Date: Sun, 18 Sep 2011 13:24:52 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110818 Icedove/3.0.11

Yes, the access handler being called 3+ times is normal for an upload/POST:

1st time, you have the chance to override 100 CONTINUE (i.e. with a 40x-message to prevent the browser from doing an upload at all). So here queueing a reply is OK, but it will prevent the upload.

2nd-N-1th time, you get the upload data (in fact, the upload data may be given to you many times, so this can be called repeatedly with more data, depending on the upload size). Queueing here is NOT ok, upload-size is non-zero.

N-th time (often 3rd for small data), you are supposed to generate the 'normal' response to the browser, that the upload is done is indicated by upload-size being (again) zero.

As I said, slightly goofy API (and pretty much the only thing I'd likely do differently if backwards-compatibility didn't matter, but it is not so bad that I'd break compatibility to fix it).

Happy hacking!

Christian

On 09/18/2011 01:17 PM, Peter Ross wrote:
On Sun, Sep 18, 2011 at 08:03:00AM +0200, Christian Grothoff wrote:
Dear Peter,

I suspect you're simply queueing your response too early.  The API
may not be 100%-intuitive here: if you have an upload (and did not
replace the 100-CONTINUE with an error), you need to wait for MHD to
call you with an '*upload_size' of zero before giving your response.
 From what you write about the state we're at, your code does not do
this.

Thanks for the speedy response. Your suggestion works! Note that in my
example, AccessHandlder is called *three* times per POST request. The
first time upload_data_size is zero, second time its non-zero, and then
finally its zero again.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)




reply via email to

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