http: rename HttpdException to HTTPException
This commit is contained in:
parent
caacad97dd
commit
37a7b67164
2 changed files with 10 additions and 9 deletions
7
http.d
7
http.d
|
@ -1,5 +1,7 @@
|
|||
module http;
|
||||
|
||||
import std.exception;
|
||||
|
||||
enum HTTPMethod
|
||||
{
|
||||
GET,
|
||||
|
@ -32,4 +34,9 @@ struct HTTPResponse
|
|||
string httpVersion = "HTTP/1.1";
|
||||
}
|
||||
|
||||
class HTTPException : Exception
|
||||
{
|
||||
mixin basicExceptionCtors;
|
||||
}
|
||||
|
||||
alias HTTPModule = HTTPResponse delegate (HTTPRequest);
|
||||
|
|
12
httpd.d
12
httpd.d
|
@ -5,17 +5,11 @@ import http;
|
|||
import std.algorithm;
|
||||
import std.array;
|
||||
import std.conv;
|
||||
import std.exception;
|
||||
import std.format;
|
||||
import std.socket;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
|
||||
class HttpdException : Exception
|
||||
{
|
||||
mixin basicExceptionCtors;
|
||||
}
|
||||
|
||||
int
|
||||
main(string[] args)
|
||||
{
|
||||
|
@ -65,7 +59,7 @@ tryRequest(char[] requestBody)
|
|||
|| rq.resource == "/index.html"
|
||||
? respondWithPage(import("index.html"))
|
||||
: failurePage("404 Not Found");
|
||||
} catch (HttpdException e)
|
||||
} catch (HTTPException e)
|
||||
return failurePage(e.msg);
|
||||
}
|
||||
|
||||
|
@ -172,7 +166,7 @@ parseHTTPRequestHeading(string heading)
|
|||
result.method = HTTPMethod.TRACE;
|
||||
break;
|
||||
default:
|
||||
throw new HttpdException("400 Bad Request");
|
||||
throw new HTTPException("400 Bad Request");
|
||||
}
|
||||
|
||||
tup = heading.findSplit(" ");
|
||||
|
@ -183,7 +177,7 @@ parseHTTPRequestHeading(string heading)
|
|||
params = params.length == path.length ? "" : params;
|
||||
|
||||
if (path.length == 0 || path[0] != '/')
|
||||
throw new HttpdException("400 Bad Request");
|
||||
throw new HTTPException("400 Bad Request");
|
||||
|
||||
result.path = path;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue