libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] How to determine the file size for an upload and how


From: Christian Grothoff
Subject: Re: [libmicrohttpd] How to determine the file size for an upload and how to read complete query string
Date: Tue, 03 Nov 2015 23:03:16 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 11/03/2015 06:55 PM, Dirk Brinkmeier wrote:
> Hi.
> 
> I'm very excited in using libmicrohttpd.
> It has helped me a lot to develop a web server enabled application!
> 
> But I have 2 questions:
> 
> The first is regarding the complete size of a POSTed upload (e.g. file
> upload).
> Currently I'm using the value delivered by:
> 
> MHD_lookup_connection_value(connection, MHD_HEADER_KIND,
> MHD_HTTP_HEADER_CONTENT_LENGTH)
> 
> But this value always seems to be higher than the actual data that is sent.
> Or in other words it is higher than the file size to be uploaded.
> So I wait for *upload_data_size to be empty an then I assume that the
> POST upload is finished.

Sure, that also works.

> But I can't verify the uploaded file size to the real file size.
> 
> Is the any chance to estimate the correct file size for an upload?

Odd, could you have a broken client doing the upload?

> The second question belongs to requests that contains query data.
> For example:
> https://localhost:8099/json/T_Personal.json?order=asc&limit=10&offset=0&_=1436290313274
> 
> 
> I'm reading each parameter by calling MHD_lookup_connection_value:
> MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "order");
> MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "offset");
> MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "limit");
> MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "search");
> MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "_");
> 
> This has the disadvantage that I always have to know the parameters that
> I expect.
> Is there a way to get the complete query string (for parsing it
> afterwards in my application)?
> In the example above "order=asc&limit=10&offset=0&_=1436290313274"

You should probably use MHD_get_connection_values(), that way you don't
have to parse the string yourself.

Happy hacking!

Christian




reply via email to

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