From 6ac53d4c783340ae9139c7f4dcfe9bfddace5892 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 25 Sep 2016 02:57:21 +0200 Subject: runserver: reimplemented http server without libevent yeah, this patch implements a "complete" http server for static files. It is not the best code possible, and would be easily DDoS'able if used in production, as it spawns a thread for each request, without limiting. I'm sickish and this is the best code I can deliver now. At least it works! ;) --- Makefile.am | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 7ecb21a..12cfad8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,6 +39,9 @@ noinst_HEADERS = \ src/blogc/renderer.h \ src/blogc/source-parser.h \ src/blogc/template-parser.h \ + src/blogc-runserver/httpd.h \ + src/blogc-runserver/httpd-utils.h \ + src/blogc-runserver/mime.h \ src/common/config-parser.h \ src/common/error.h \ src/common/file.h \ @@ -68,6 +71,10 @@ if BUILD_RUNSERVER bin_PROGRAMS += \ blogc-runserver \ $(NULL) + +noinst_LTLIBRARIES += \ + libblogc_runserver.la \ + $(NULL) endif check_PROGRAMS = \ @@ -142,13 +149,29 @@ blogc_runserver_SOURCES = \ blogc_runserver_CFLAGS = \ $(AM_CFLAGS) \ - $(LIBEVENT_CFLAGS) \ + $(PTHREAD_CFLAGS) \ $(NULL) blogc_runserver_LDADD = \ - $(LIBEVENT_LIBS) \ + $(PTHREAD_LIBS) \ + libblogc_runserver.la \ libblogc_common.la \ $(NULL) + +libblogc_runserver_la_SOURCES = \ + src/blogc-runserver/httpd.c \ + src/blogc-runserver/httpd-utils.c \ + src/blogc-runserver/mime.c \ + $(NULL) + +libblogc_runserver_la_CFLAGS = \ + $(AM_CFLAGS) \ + $(PTHREAD_CFLAGS) \ + $(NULL) + +libblogc_runserver_la_LIBADD = \ + $(PTHREAD_LIBS) \ + $(NULL) endif @@ -456,6 +479,51 @@ tests_common_check_utils_LDADD = \ libblogc_common.la \ $(NULL) +if BUILD_RUNSERVER +check_PROGRAMS += \ + tests/blogc-runserver/check_httpd_utils \ + tests/blogc-runserver/check_mime \ + $(NULL) + +tests_blogc_runserver_check_httpd_utils_SOURCES = \ + tests/blogc-runserver/check_httpd_utils.c \ + $(NULL) + +tests_blogc_runserver_check_httpd_utils_CFLAGS = \ + $(CMOCKA_CFLAGS) \ + $(NULL) + +tests_blogc_runserver_check_httpd_utils_LDFLAGS = \ + -no-install \ + -Wl,--wrap=read \ + $(NULL) + +tests_blogc_runserver_check_httpd_utils_LDADD = \ + $(CMOCKA_LIBS) \ + libblogc_runserver.la \ + libblogc_common.la \ + $(NULL) + +tests_blogc_runserver_check_mime_SOURCES = \ + tests/blogc-runserver/check_mime.c \ + $(NULL) + +tests_blogc_runserver_check_mime_CFLAGS = \ + $(CMOCKA_CFLAGS) \ + $(NULL) + +tests_blogc_runserver_check_mime_LDFLAGS = \ + -no-install \ + -Wl,--wrap=access \ + $(NULL) + +tests_blogc_runserver_check_mime_LDADD = \ + $(CMOCKA_LIBS) \ + libblogc_runserver.la \ + libblogc_common.la \ + $(NULL) +endif + endif TESTS = \ -- cgit v1.2.3-18-g5258