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: Kenneth Mastro
Subject: Re: [libmicrohttpd] How to determine the file size for an upload and how to read complete query string
Date: Tue, 3 Nov 2015 13:33:55 -0500

I can't help you with the first problem (POST file upload size).  I don't know, but there may not be a way to do what you want with the HTTP protocol.  Like you, I just wait for the upload_data_size to be 0.  That may be all you CAN do given HTTP.  (I honestly don't know.)

For your second question.. I use 'MHD_get_connection_values' to parse the query string.  You give it a callback function and, if you need it, a void* pointer. (I'm using C++, but I use mine to store an unordered_map to put the key/value pairs in)  In the callback, you get your given pointer plus the key and value from a single query string item.  The callback gets called as many times as there are parameters.

I think this function is what you're after.  I'm sure there's documentation on it somewhere, but it's pretty straight forward to use after you get the hang of it.


Ken



On Tue, Nov 3, 2015 at 12:55 PM, Dirk Brinkmeier <address@hidden> 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.
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?


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"


Hope you can give me some hints...
I also hope that I don't have missed some basic chapters in the documentation ;-)

Thanks a lot in advance,
Dirk.







reply via email to

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