Upgraded to handy-httpd v8.1.0

This commit is contained in:
Andrew Lalis 2024-01-25 20:31:01 -05:00
parent af0b8b0aab
commit 526f150482
3 changed files with 8 additions and 7 deletions

View File

@ -6,7 +6,7 @@
"dependencies": {
"d-properties": "~>1.0.4",
"d2sqlite3": "~>1.0.0",
"handy-httpd": "~>7.7.0"
"handy-httpd": "~>8.1.0"
},
"subConfigurations": {
"d2sqlite3": "all-included"

View File

@ -1,11 +1,12 @@
{
"fileVersion": 1,
"versions": {
"d-properties": "1.0.4",
"d-properties": "1.0.5",
"d2sqlite3": "1.0.0",
"handy-httpd": "7.7.0",
"handy-httpd": "8.1.0",
"httparsed": "1.2.1",
"slf4d": "2.4.2",
"path-matcher": "1.1.3",
"slf4d": "2.4.3",
"streams": "3.5.0"
}
}

View File

@ -1,5 +1,5 @@
import handy_httpd;
import handy_httpd.handlers.path_delegating_handler;
import handy_httpd.handlers.path_handler;
import slf4d;
import d_properties;
import d2sqlite3;
@ -54,12 +54,12 @@ void handleVisitorLog(ref HttpRequestContext ctx) {
ctx.response.writeBodyString("Message is too long.");
return;
}
if (!ctx.request.hasHeader("X-Forwarded-For")) {
if (!ctx.request.headers.contains("X-Forwarded-For")) {
ctx.response.setStatus(HttpStatus.FORBIDDEN);
ctx.response.writeBodyString("Missing remote IP");
return;
}
string remoteAddress = ctx.request.getHeader("X-Forwarded-For");
string remoteAddress = ctx.request.headers.getFirst("X-Forwarded-For").orElseThrow();
// If the user has sent another log within the last minute, block this one.
LogEntry[] recentLogsByThisAddress = getRecentLogEntriesByRemoteAddress(remoteAddress);