+#include "inspircd.h"
+#include "iohook.h"
+#include "modules/httpd.h"
+
+#ifdef __GNUC__
+# pragma GCC diagnostic push
+#endif
+
+// Fix warnings about the use of commas at end of enumerator lists and long long
+// on C++03.
+#if defined __clang__
+# pragma clang diagnostic ignored "-Wc++11-extensions"
+# pragma clang diagnostic ignored "-Wc++11-long-long"
+#elif defined __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))
+# pragma GCC diagnostic ignored "-Wpedantic"
+# else
+# pragma GCC diagnostic ignored "-pedantic"
+# endif
+#endif
+
+// Fix warnings about shadowing in http_parser.
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wshadow"
+#endif
+
+#include <http_parser.c>
+
+#ifdef __GNUC__
+# pragma GCC diagnostic pop
+#endif
+
+class ModuleHttpServer;
+
+static ModuleHttpServer* HttpModule;
+static insp::intrusive_list<HttpServerSocket> sockets;
+static Events::ModuleEventProvider* aclevprov;
+static Events::ModuleEventProvider* reqevprov;
+static http_parser_settings parser_settings;
+
+/** A socket used for HTTP transport
+ */
+class HttpServerSocket : public BufferedSocket, public Timer, public insp::intrusive_list_node<HttpServerSocket>
+{
+ private:
+ friend class ModuleHttpServer;
+
+ http_parser parser;
+ http_parser_url url;
+ std::string ip;
+ std::string uri;
+ HTTPHeaders headers;
+ std::string body;
+ size_t total_buffers;
+ int status_code;
+
+ /** True if this object is in the cull list
+ */
+ bool waitingcull;
+ bool messagecomplete;
+
+ bool Tick(time_t currtime) CXX11_OVERRIDE
+ {
+ if (!messagecomplete)
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "HTTP socket %d timed out", GetFd());
+ Close();
+ return false;
+ }