GNU Libmicrohttpd

6.3.1 Windows; 6.3.2 macOS; 6.3.3 Customizing package compilation; 6.3.4 Multiple. 8 Choosing between 32- and 64-bit builds; 9 The standalone Rmath library. Cross-building is not possible: installing R builds a minimal version of R. HTML pages is determined by looking at the R installation and is reported by R.

GNU libmicrohttpd is a small C library that is supposed to make iteasy to run an HTTP server as part of another application.GNU Libmicrohttpd is free software and part of the GNU project. Key features that distinguishGNU Libmicrohttpd from other projects are:

  • C library: fast and small
  • API is simple, expressive and fully reentrant
  • Implementation is HTTP 1.1 compliant
  • HTTP server can listen on multiple ports
  • Four different threading modes (select, poll, pthread, thread pool)
  • Supported platforms include GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, Darwin (macOS), W32, OpenIndiana/Solaris and z/OS
  • Support for IPv6
  • Support for SHOUTcast
  • Support for incremental processing of POST data (optional)
  • Support for basic and digest authentication (optional)
  • Support for TLS (requires libgnutls, optional)
  • Binary is only about 32k (without TLS support and other optional features)

GNU Libmicrohttpd was started because the author needed an easy way to adda concurrent HTTP server to other projects. Existing alternativeswere either non-free, not reentrant, standalone, of terrible codequality or a combination thereof. Do not use GNU Libmicrohttpd if you arelooking for a standalone HTTP server, there are many other projectsout there that provide that kind of functionality already. However,if you want to be able to serve simple WWW pages from within your C orC++ application, check it out.

GNU libmicrohttpd is a GNU package.Our official GNU website can be foundat http://www.gnu.org/software/libmicrohttpd/.

Downloading Libmicrohttpd

Source Code
Libmicrohttpdcan be found on the main GNU ftp server:https://ftp.gnu.org/gnu/libmicrohttpd/(via HTTPS) andftp://ftp.gnu.org/gnu/libmicrohttpd/(via FTP). It can also be foundon the GNU mirrors;pleaseusea mirror if possible.
Debian .deb package
The debian package can be downloaded from the official debian archive.The respective packages for libmicrohttpd are libmicrohttpd and for development libmicrohttpd-dev.Backports for Debian Stable are also available.
Tar Package
The latest version can be found on GNU mirrors.If the mirror does not work, you should be able to find them on the main FTP server athttps://ftp.gnu.org/gnu/libmicrohttpd/.

Latest release is libmicrohttpd-latest.tar.gz.

Windows
Latest Windows binary is libmicrohttpd-latest-w32-bin.zip.

Documentation

In addition to the brief documentation on this webpage, wehave various other forms of documentation available:

microhttpd.h
This include file documents most of the API in detail.
Manual
A manual for Libmicrohttpd is available online, as is documentation for most GNU software. You may also find more information about Libmicrohttpd by runninginfo libmicrohttpdorman libmicrohttpd,or by looking at/usr/share/doc/libmicrohttpd/,/usr/local/doc/libmicrohttpd/,or similar directories on your system.
Tutorial
The GNU Libmicrohttpd tutorial is available as one document in pdf and html formats.
Compatibility
API/ABI compatibility report comparing most recent GNU libmicrohttpd versions

Mailing lists

Libmicrohttpd uses thelibmicrohttpdmailinglist to discuss all aspects ofLibmicrohttpd,including support, development and enhancement requests, as well as bug reports.

Announcements aboutLibmicrohttpdand most other GNU software are made oninfo-gnu(archive).If you only want to get notifications about Libmicrohttpd, wesuggest you subscribe to the project atfreshmeat.

Security reports that should not be made immediately public can besent directly to themaintainer. If there is no response to an urgent issue, you canescalate to the generalsecuritymailing list for advice.

Getting involved

Development ofLibmicrohttpd,and GNU in general, is a volunteer effort, and you can contribute. Forinformation, please read How to help GNU. If you'dlike to get involved, it's a good idea to join the discussion mailinglist (see above).

Development
Known bugs and open feature requests are tracked in our bugtracker. You need to sign up for a reporter account. Please make sure you report bugs under libmicrohttpd and not under any of the other projects.
Subversion access

You can access the current development version of libmicrohttpd using

Our website is kept at

Quick Introduction

Dependencies
GNU Libmicrohttpd can be used without any dependencies; however,for TLS (HTTPS) support it requirelibgnutls.Furthermore, the testcases use libcurl. Some extendedtestcases also use zzuf and socat (to simulateclients that violate the HTTP protocols). You can compile and useGNU Libmicrohttpd without installing libgnutls, libcurl, zzuf orsocat.
A minimal example
Before including the microhttpd.h header, you may need toinclude the headers of your operating system that define the size_t,fd_set, socklen_t and struct sockaddr datatypes and define MHD_PLATFORM_H. Otherwise,the microhttpd.h header will attempt to include theappropriate headers automatically, which may fail for more exoticplatforms.

The following is a minimal example for GNU/Linux (included in the distribution):

Threading modes
StandaloneThe example above uses the simplest threading mode,MHD_USE_THREAD_PER_CONNECTION. In this mode, MHD starts onethread to listen on the port for new connections and then spawns a newthread to handle each connection. This mode is great if the HTTPserver has hardly any state that is shared between connections (nosynchronization issues!) and may need to perform blocking operations(such as extensive IO or running of code) to handle an individualconnection.

The second threading mode, MHD_USE_SELECT_INTERNALLY, usesonly a single thread to handle listening on the port and processing ofrequests. This mode is preferable if spawning a thread for eachconnection would be costly. If the HTTP server is able to quicklyproduce responses without much computational overhead for eachconnection, this mode can be a great choice. Note that MHD willstill start a single thread for itself -- this way, the main programcan continue with its operations after calling MHD_daemon_start.Naturally, if the HTTP server needs to interact withshared state in the main application, synchronization will berequired. If such synchronization in code providing a responseresults in blocking, all HTTP server operations on all connectionswill stall. This mode is a bad choice if response data (for responsesgenerated using the MHD_create_response_from_callbackfunction) cannot always be provided instantly. The reason is that thecode generating responses should not block (since that would block allother connections) and on the other hand, if response data is notavailable immediately, MHD will start to busy wait on it. Use thefirst mode if you want to block on providing response data in thecallback, or the last mode if you want to use a more event-drivenmode with one big select loop.

The third mode combines a thread pool withthe MHD_USE_SELECT_INTERNALLYRfactor le mans 1970 track machine. mode, which can benefitimplementations that require scalability. As said before, by defaultthis mode only uses a single thread. When combined with the thread pool option, itis possible to handle multiple connections with multiple threads. Thenumber of threads is specified using theMHD_OPTION_THREAD_POOL_SIZE; any value greater than one forthis option will activate the use of the thread pool. In contrast tothe MHD_USE_THREAD_PER_CONNECTION mode (where each threadhandles one and only one connection), threads in the pool can handle alarge number of concurrent connections. UsingMHD_USE_SELECT_INTERNALLY in combination with a thread poolis typically the most scalable (but also hardest to debug) mode ofoperation for MHD.

The fourth threading mode (used when no specific flag is given), usesno threads. Instead, the main application must (periodically) requestfile descriptor sets from MHD, perform a select call and then callMHD_run. MHD_run will then process HTTP requests asusual and return. MHD_run is guaranteed to not block;however, access handlers and response processing callbacks that itinvokes may block. This mode is useful if a single-threadedimplementation is desired and in particular if the main applicationalready uses a select loop for its processing. If the application isnot ready to provide a response, it can just return zero for thenumber of bytes read and use its file descriptors in the externalselect loop to wake up and continue once the data is ready -- MHD willunlist the socket from the write set if the application failed toprovide response data (this only happens in this mode).

The testcases provided include examples for using each of thethreading modes.

Generating responses
MHD provides various functions to create struct MHD_Responseobjects. A response consists of a set of HTTP headers and a (possiblyempty) body. The three main ways to create a response are either byspecifying a given (fixed-size) body(MHD_create_response_from_data), by providing a function oftype MHD_ContentReaderCallback which provides portions of theresponse as needed or by providing an open file descriptor(MHD_create_response_from_fd). The first responseconstruction is great for small and in particular static webpages thatfit into memory. The second response type should be used for responseobjects where the size is initially not known or where the responsemaybe too large to fit into memory. Finally, using a file descriptorcan be used on Linux systems to use the highly efficientsendfile call for the file transfer.

A response is used by calling MHD_queue_response which sendsthe response back to the client on the specified connection. Oncecreated, a response object can be used any number of times.Internally, each response uses a reference counter. The response isfreed once the reference counter reaches zero. The HTTP server shouldcall MHD_destroy_response when a response object is no longerneeded, that is, the server will not call MHD_queue_responseagain using this response object. Note that this does not mean thatthe response will be immediately destroyed -- destruction may bedelayed until sending of the response is complete on all connectionsthat have the response in the queue.

Queueing responses
Clients should never create a '100 CONTINUE' response. MHDhandles '100 CONTINUE' internally and only allows clients toqueue a single response per connection. Furthermore, clients must notqueue a response before the request has been fully received (exceptin the case of rejecting PUT or POST operations in HTTP 1.1). If aclient attempts to queue multiple responses or attempts to queue aresponse early, MHD_queue_response will fail (and returnMHD_NO).

The callback function for the respective URL will be called at leasttwice. The first call happens after the server has received theheaders. The client should use the last void** argument tostore internal context for the session. The first call to thecallback function is mostly for this type of initialization and forinternal access checks. At least, the callback function should'remember' that the first call with just the headers hashappened. Queueing a response during the first call (for a givenconnection) should only be used for errors -- if the client queues aresponse during this first call, a 100 CONTINUE response willbe suppressed, the request body will not be read and the connectionwill be closed after sending the response. After the first call, thecallback function will be called with upload data. Until*upload_data_size is zero, the callback may not queue aresponse, any such attempt will fail. The callback function shouldupdate *upload_data_size to indicate how many bytes wereprocessed. Depending on available buffer space, incrementalprocessing of the upload maybe required. Once all of the upload datahas been processed, MHD will call the callback a second time with*upload_data_size being zero. At this point, the callbackshould queue a 'normal' response. If queueing a response isnot possible, the callback may either block or simply not queue aresponse depending on the threading mode that is used. If thecallback does not queue a response at this point, MHD will either(eventually) timeout the connection or keep calling it.

Parsing of POST requests
MHD includes a set of three functions for parsing and processing datareceived in POST requests. The functions allow incremental parsingand processing of POST data. Only a tiny fraction of the overall POSTdata needs to fit into memory. As a result, applications using MHDcan support POST requests of arbitrary size. POST data is processedby providing MHD with a callback function that is called on portionsof the received values. The POST parser itself is invoked repeatedlywhenever more input bytes become available. MHD supports both uri-and multipart/form-encoded POST data.
Memory Management
The application can determine the size of buffers that MHD should usefor handling of HTTP requests and parsing of POST data. This way, MHDusers can trade-off processing time and memory utilization.Applications can limit the overall number of connections MHD willaccept, as well as the total amount of memory used per connection.MHD will gracefully handle all out-of-memory situations (by closingthe connection and cleaning up any remaining state).
Related projects
Projects that use libmicrohttpd
If you write an application that uses libmicrohttpd, pleaselet us know so that we can add you to the list!
Alternatives
If you are aware of a competing library that might be a better fit forsome developers, please let us know so that we can add it to the list!

Licensing

Libmicrohttpdis free software; you can redistribute it and/or modify it under theGNULGPL v2.1 or at youroption any laterversion. If you disable HTTPS/TLS support, you can also choosethe second license,the eCosLicense. If you have questions about licensing, please contactthemaintainer.

«14243444546474863»
  • I ran in the same problem as reported by @mtd91429 Zotfile will report an error on not being able to rename a file when added to a publication entry (via drag and drop in my case) and the same when trying to change an existing.
    I found the reason though. The error only occurred when the publication entry didn't have an author field filled in. I guess because it wants to build the file name out of the author name and does not know what to do when that one is empty. What it should do is simply ignore the author or display a warning about this.
    I'm experiencing the same behavior. What's strange is that this has only been happening recently—for as long as I've used zotfile to rename files, it's always ignored empty fields and just started the file name with the first available information. Not sure what to make of this, but for now I'll just have to make sure every entry has an author before I try to rename.
  • edited February 18, 2016
    Thanks for reporting (and particularly figuring out how to reproduce it). Just fixed it. Already on github and version 4.2.1 is under review. I hope it's approved within the next 48 hours.
    Edit: Yes, it was introduced this one of the recent additions.
  • @Joscha Oh so there is a github issue tracker. Good to know for the future ;-) or do you still prefer 'bug reports' in this long thread as pointed out by the home page?
  • @dietmarw: Github is good for concrete bug reports (usually reproducible). Any support requests should go here though. And yes, unfortunately this thread is a mess.. :(
    But I am not going to maintain a separate forum and usually don't look at other threads in the zotero forum.
  • Sorry for my English. I'm going to try to make my question.
    I use zotefile and I saved pdf in a Dropbox carpet. The problem is, when I try to open the pdf with zotpad, I can't. Zotpad send to me an error message. I use zotpad to manage pdf in my iPad. Can I do anything to fix it?
  • Beatriz, you'll want to contact ZotPad support for that.
  • When I try to rename an attached PDF from an online group, and move it to a specific local folder, zotfile does not move the file properly. It looks like it’s renaming the local file just fine (placed in ~AppDataRoamingZoteroZoteroProfilesskt3imfr.defaultzoterostorage9NVA9I72) but it doesn’t move/copy the file to the folder where I wanted.
    When I tried to rename an attachment PDF in my personal library, it seemed to be working just fine, and moved the file as expected
    I get the following error in the log:
    [JavaScript Error: '1457369944974 Toolkit.Telemetry ERROR TelemetryStorage::loadAbortedSessionPing - error removing ping: PingReadError JS Stack trace: PingReadError@TelemetryStorage.jsm:80:15 < TelemetryStorageImpl.loadPingFile<@TelemetryStorage.jsm:1440:13' {file: 'resource://gre/modules/Log.jsm' line: 749}]
    [JavaScript Error: 'no element found' {file: 'https://khauns13:********@api.zotero.org/groups/494424/items/SM94NBD8/file?auth=1&iskey=1&version=1&info=1' line: 1}]
    version => 4.0.28.7, platform => Win32, oscpu => Windows NT 10.0; WOW64, locale => en-US, appName => Zotero, appVersion => 4.0.28.7
    Is there anything I can do to fix this, or is it a bug?
  • since groups don't allow links to Files in Zotero, ZotFile can't move files in groups (if that's not clear, try doing what you'd like to do manually and you'll see it's not possible).
  • I'm also suddenly having problems renaming attachments w/custom folder after upgrading to 4.2.2 (Zotero Standalone Mac 4.0.29.2):
    1) drag PDF to Zotero
    2) retrieve metadata - Zotero copies to new folder under ~/zotero/storage
    3) Manage attachments > Rename attachment
    4) Zotfile throws 'unknown error!' plus 'The source folder is not valid'.
    5) Clicking to copy 'unknown error!' to clipboard gives {} as for mtd91429 and denlinkd
    6) Curiously, it appears Zotfile *has* successfully renamed and moved the file - as per my rules, it is now renamed, in my custom folder in an author-last-name subfolder. However this isn't recognised by Zotero and when I try to open it a 'File Not Found' error appears.
    7) Manually fixing the link works, but the PDF filename is not updated from within Zotero itself.
    Zotero also knows about the location of the custom folder; this setup has been working fine for some years until the update(s) (though I can't work out if it was the Zotero update that broke this, or the Zotfile update).
  • What are your exact settings? Renaming rules etc? Can you try whether 4.2.1 works? You can get it here: https://addons.mozilla.org/en-us/firefox/addon/zotfile/versions/
    Do you have some programming experience? Just asking because I would let you run some code to pin down the problem.
  • 4.2.1 works.
    General Settings:
    Location of files: custom location: /path/to/my/Articles
    Use subfolder defined by /%a
    Renaming Rules
    Format for all types except patents: {%a} {%y} {%t}
    Format for Patents: {%a_}{%y_}{%t}
    [odd, actually, as what files get renamed to is author_year_title.pdf, which is what I want]
    Additional settings:
    Delimiter between multiple authors: &
    Change to lower case
    Replace blanks
    Maximum length of title: 80
    Maximum number of authors: 1
    Number of authors to display when authors are omitted: 1
    [things not listed are not checked]
    Happy to run some debugging code if that's useful.
  • edited March 14, 2016
    Hello,
    I've just discovered ZotFile. It's just what i'm looking for. Thanks for all !!
    I've one question (may be already asked, but did not find a topic by searching).
    I want to translocate a pdf by renaming it from one sourcefolder to a targetfolder. If in the targetfolder there's already a pdf with that name, Zotfile still copies the file by adding a suffixnumber at the filename.
    Is it possible to let Zotfile not to take action? This is to avoid duplicates in the target map (in my case: a big shared institutionfolder with 26 subfolders).
  • This to confirm that installing the older version of Zotfile (4.2.1) seems to fix the problem. I have been using Zotfile for a while now without any problems until it stopped working when I tried to back up my Library.
    Here are some of my Zotfile preferences:
    General Settings:
    Location of Files: Custom location: C:UsersmynameDropboxzotero PDFs
    Location of Files on Tablet: C:UsersmynameDropboxTablet
    Renaming Rules:
    Format for all types except patents: {%a_}{%y_}{%t}
    Format for Patents: {%a_}{%y_}{%t}
    Additional Settings:
    Delimiter between multiple authors: _
    Truncate title after . or : or ?
    Maximum length of title: 80
    Maximum number of authors: 2
    Number of authors to display when authors are omitted: 1
    Add suffix when authors are omitted: et al
  • loubnael, do you also get the 'The source folder is not valid' message?
    What are both of your source folder settings?
    Can someone why has this problem try this:
    - Use Zotero for Firefox
    - Check whether the same error occurs with the 'The source folder is not valid' warning/error
    - Allow Scratchpad to run in the browser context (see https://developer.mozilla.org/en-US/docs/Tools/Scratchpad under 'Running Scratchpad in the browser context')
    - Open Scratchpad under Tools -> Web Developer -> Scratchpad
    - Change Environment to Browser (Environment -> Browser)
    - Run this code (cmd + L to insert results as comment)
    Zotero.ZotFile.getSourceDir(true)
    Are you getting the same error message?
  • @Joscha
    Before the problem was fixed, the message “The source folder is not valid” kept appearing whenever I tried to rename my attachments manually.
    I was trying to download Zotero for Firefox (since I have only been using the standalone for quite some time now) and I was trying to find my way around using Scratchpad when the strangest thing happened: all my Firefox add-ons/extensions suddenly got deleted and now they take for ever to install. I don’t know what exactly happened and I apologize for the inconvenience.
  • What do you mean with 'Before the problem was fixed'? In which version? What do you mean with 'rename my attachments manually'? What is your source folder?
  • I think I fixed it. Can you try the current version on github?
  • 1. Before the problem was fixed: that is before I replaced the last version of Zotfile with an older one(4.2.1); the replacement fixed the error and Zotfile is working once again.
    2. Rename my attachments manually: when Zotfile wouldn’t rename my uploaded documents automatically, I tried to use one of Zotfile’s listed features to rename them myself: Right Click> Manage Attachments> Rename Attachments.
    3. I am using a custom location (Dropbox) to store my files: C:UsersmynameDropboxzotero PDFs. (Not sure if this answers your question though)
  • Any chance you can try the current version on github?
  • edited March 14, 2016
    @joscha
    If you mean the released version(4.2.2) provided in the following link: https://addons.mozilla.org/en-US/firefox/addon/zotfile/, I have tried it and it didn’t work (the error still appears). But if you mean the development version, I downloaded the zip file, extracted it, but I can’t seem to understand the third step: “recreate .zip file containing all the files at the top level, i.e., install.rdf and the chrome directory need to be at the root of the .zip file and not under Zotfile.”
  • The development version on github. Here is the xpi: http://www.columbia.edu/~jpl2136/zotfile-4.2.3-fx.xpi
  • The message about the source folder not being valid doesn't appear anymore, but Zotfile (4.2.3) doesn’t seem to work for me. When I uploaded a PDF as an attachment, Zotfile didn’t rename it and two messages appeared (they did appear before as well) stating that an “unknown error” has occurred and that “attachments skipped because they are top-level items, snapshots or the file does not exist.”
  • loubnael, you will have to be more specific. First, the problem was the same in 4.2.2 and 4.2.1? Or only since 4.2.2? Second, what are the exact steps to reproduce this? What does 'uploaded a PDF as an attachment' mean? Drag-and-drop? etc
    Thanks!
  • Hello,
    Sorry for reposting my question. Is it possible to give me some answer? Even a short one is ok for me. Thanks a lot !
    'Hello,
    I've just discovered ZotFile. It's just what i'm looking for. Thanks for all !!
    I've one question (may be already asked, but did not find a topic by searching).
    I want to rename and translocate a pdf it with zotfile from one sourcefolder to a targetfolder. If in the targetfolder there's already a pdf with that name, Zotfile still copies the file by adding a suffixnumber at the filename.
    Is it possible to let Zotfile not to take action? This is to avoid duplicates in the target map (in my case: a big shared institutionfolder with 26 subfolders).'
  • edited March 15, 2016
    @Joscha
    1. Uploading a PDF :
    a. Right Click
    b. Add attachment
    c. Attach Stored Copy of File
    2. Zotfile 4.2.1 is working just fine.
    3. Zotfile 4.2.2 : when I right click on the attached PDF and try
    to rename it (Manage attachments>Rename attachments), 3
    messages appear:
    a. Zotfile Error: Unknown Error!
    b. Zotfile Error: The source folder is not valid. Please
    change the source folder under Zotero-Actions-Zotfile
    preferences.You might have to use a custom folder.
    c. Zotfile: Renamed attachments X author_title.pdf
    4. Zotfile 4.2.3 : when I right click on the attached PDF and
    try to rename it(Manage attachments>Rename attachments), 2
    messages appear:
    a. Zotfile Error: Unknown Error!
    b. Zotfile: Renamed Attachments X author_title.pdf
    5. The “Drag and drop>Right Click>Retrieve Metadata for PDF'
    works in all three versions, but the “right click>Manage
    Attachments>Rename Attachments' is only working in Zotfile
    4.2.1.
    Thank you and I hope this answers your questions.
  • WJan, no, that's currently not possible. Happy to accept a pull request if you want to implement it.
    loubnael, can you try this version and report about the messages that appear? It is a version with specific debug messages. The same error should still occur, just 2-3 additional messages.
    http://www.columbia.edu/~jpl2136/zotfile-4.2.3.99-fx.xpi
  • Joscha,
    The same two massages that appeared in the case of Zotfile 4.2.3 along with a debug message indicating the location of the PDF file in Zotero's storage folder.