http: split structures into module http
This commit is contained in:
parent
03201fd28d
commit
d54bc367f1
3 changed files with 36 additions and 33 deletions
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
||||||
DC = ldc2
|
DC = ldc2
|
||||||
CFLAGS = -Jstatic -Oz
|
CFLAGS = -Jstatic -Oz
|
||||||
|
|
||||||
OBJS = httpd.o mimetypes.o
|
OBJS = httpd.o http.o mimetypes.o
|
||||||
|
|
||||||
all: httpd
|
all: httpd
|
||||||
|
|
||||||
|
|
33
http.d
Normal file
33
http.d
Normal 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
34
httpd.d
|
@ -1,5 +1,7 @@
|
||||||
module httpd;
|
module httpd;
|
||||||
|
|
||||||
|
import http;
|
||||||
|
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
import std.array;
|
import std.array;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
@ -9,38 +11,6 @@ import std.socket;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.string;
|
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
|
class HttpdException : Exception
|
||||||
{
|
{
|
||||||
mixin basicExceptionCtors;
|
mixin basicExceptionCtors;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue