> For large files you should use > MHD_create_response_from_fd_at_offset64(). > > That will do the right thing. >
Alas, in my case the 'files' are not something like FS files or system objects exactly, they're blobs in DB, really. And I read chunks from DB blobs (this is possible for postgresql) and feed them to callback. But there're a plenty of other cases when data is not a file descriptor resource, like transfer of packets from other network, when data come chunked. And I think there're many more cases for such use. Using callback is the most universal way for processing any abstract data. And it's very useful for custom deflating/inflating the packets too, considering the block sizes, headers, etc. So I see the callback creating form as the most useful one for work with abstract binary data in terms of libmicrohttpd. And it's quite robust even in HTTP/1.1 when using keep-alive connections. > Properly supporting HTTP/2 and HTTP/3 will take developer time (and thus > funding) that we currently do not have. Evgeny and I would like to see > it happen eventually -- alas primarily in the context of the > microhttpd2.h / improved v2.0-API effort. > > Which itself is also stalled because we'd really need to find a huge > chunk of time to spend on this to make it happen. So contributions are > in principle welcome -- alas it is a huge task that I doubt can be done > purely with volunteers in a timely fashion. > I know it's a big task. But HTTP/2 is much faster and HTTP/3 is even more robust. I haven't looked at HTTP/3 and QUIC in details yet but I merged the HTTP/2 version I found on github (https://github.com/maru/libmicrohttpd-http2) with stable libmicrohttpd and keep the merged variant on my server: https://git.ironbug.org/libmicrohttpd-http2/ Just in case someone is curious. But I also try to improve the code for responses reuse. I want to implement a robust caching for responses, which is a very useful for the server I write, and I try to eliminate any unnecessary repeated operations that can be omitted wherever possible. So there're a little more than just a merge. I experimented there with reuse of responses and made little tweaks to make it work. It's not up to date with the newest released version of stable libmicrohttpd yet, but I will review the code for merging it up as I get some spare time for this. I cannot say I checked all possible variants, they're too many, but for my use case it works fine, both HTTP/1.1 and HTTP/2. I tested it with very intensive traffic exchange and it seems good enough for my pet project. Sincerely, Yana A. Kireyonok aka Iron Bug