[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] largepost.c reset connection when file already exist
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] largepost.c reset connection when file already exists |
Date: |
Tue, 14 Mar 2017 02:45:32 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
On 03/11/2017 03:39 PM, Vitaliy T wrote:
> Still there is an issue with re-open a file. Patch applied below to avoid it.
Thanks, Fixed as suggested in 1855c73c..59268ccf.
> Offtopic:
> Are there plans to "say" libmicrohttpd to "clear" network buffers when
> something goes wrong and we are ready to send a response?
The HTTP protocol requires us to read everything at that time (we did
send 100 continue), and so MHD requires you to explicitly toss all the
data. Which is really comparatively cheap, so shouldn't be a big deal.
> Currently, my fears about reading the whole request was confirmed
> (in case of largepost.c the answer_to_connection() function will be
> called as many times as needed).
Yes. If you want to avoid this, a better method would be to not have
the filename inside the POST upload data (as is done in the example),
but instead in the URL or some other place in the HTTP header. Then,
you can check upon the *first* call of "answer_to_connection", and
immediately send an error code back if there is a serious problem
detectable at that time. If the client uses "Expect: 100 continue",
this will avoid the upload of the entire HTTP payload.
signature.asc
Description: OpenPGP digital signature