http: split structures into module http

This commit is contained in:
Jeremy Baxter 2024-08-07 13:24:59 +12:00
parent 03201fd28d
commit d54bc367f1
3 changed files with 36 additions and 33 deletions

View file

@ -1,7 +1,7 @@
DC = ldc2
CFLAGS = -Jstatic -Oz
OBJS = httpd.o mimetypes.o
OBJS = httpd.o http.o mimetypes.o
all: httpd

33
http.d Normal file
View file

@ -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";
}

34
httpd.d
View file

@ -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;