From d54bc367f1c391531a64075c29ab4fae10560e1d Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Wed, 7 Aug 2024 13:24:59 +1200 Subject: [PATCH] http: split structures into module http --- Makefile | 2 +- http.d | 33 +++++++++++++++++++++++++++++++++ httpd.d | 34 ++-------------------------------- 3 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 http.d 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;