diff --git a/Makefile b/Makefile index 4166432..36b0cbb 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ DC = ldc2 CFLAGS = -Jstatic -Oz -OBJS = httpd.o mimetypes.o +OBJS = httpd.o http.o mimetypes.o all: httpd diff --git a/http.d b/http.d new file mode 100644 index 0000000..45abd2b --- /dev/null +++ b/http.d @@ -0,0 +1,33 @@ +module http; + +enum HTTPMethod +{ + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + invalid +} + +struct HTTPRequest +{ + HTTPMethod method; + string resource; + string[string] parameters; + string[string] headers; + string httpVersion = "HTTP/1.1"; + + alias path = resource; +} + +struct HTTPResponse +{ + string status; + string[string] headers; + string responseBody; + string httpVersion = "HTTP/1.1"; +} diff --git a/httpd.d b/httpd.d index 69d19e6..2a4d251 100644 --- a/httpd.d +++ b/httpd.d @@ -1,5 +1,7 @@ module httpd; +import http; + import std.algorithm; import std.array; import std.conv; @@ -9,38 +11,6 @@ import std.socket; import std.stdio; import std.string; -enum HTTPMethod -{ - GET, - HEAD, - POST, - PUT, - DELETE, - CONNECT, - OPTIONS, - TRACE, - invalid -} - -struct HTTPRequest -{ - HTTPMethod method; - string resource; - string[string] parameters; - string[string] headers; - string httpVersion = "HTTP/1.1"; - - alias path = resource; -} - -struct HTTPResponse -{ - string status; - string[string] headers; - string responseBody; - string httpVersion = "HTTP/1.1"; -} - class HttpdException : Exception { mixin basicExceptionCtors;