Remove some debug statements; make route error more specific.

This commit is contained in:
Jordan Bancino 2022-12-14 18:41:01 +00:00
parent e37e6f1bb8
commit 5080d066ab
2 changed files with 20 additions and 23 deletions

View file

@ -32,8 +32,14 @@ as well, so you can discuss your progress and ask questions.
.Pp
Not released yet.
.Pp
.Nm
homeserver changes and fixes:
Changes:
.Bl -bullet
.It
Improved HTTP request logging by removing unnecessary
log entries and making errors more specific.
.El
.Pp
Bug fixes:
.Pp
.Bl -bullet
.It
@ -41,18 +47,18 @@ Fixed a memory leak that would occur when parsing an invalid
JSON object.
.It
Fixed an edge case where HTTP response headers were being
sent before they were set properly, causing the server to
sent before they were properly set, causing the server to
report a status of 200 even when that wasn't the desired
status.
.It
Fixed a few memory leaks in the HTTP parameter decoder that
would occur in some edge cases.
.It
Fixed an "off-by-one" error in the HTTP server that
prevented GET parameters from being parsed.
Fixed an "off-by-one" error in the HTTP server request
parser that prevented GET parameters from being parsed.
.El
.Pp
Other changes and fixes included in this release:
Misc.:
.Bl -bullet
.It
Fixed a bug in

View file

@ -37,18 +37,14 @@ void
MatrixHttpHandler(HttpServerContext * context, void *argp)
{
MatrixHttpHandlerArgs *args = (MatrixHttpHandlerArgs *) argp;
LogConfig *lc = args->lc;
HashMap *requestHeaders = HttpRequestHeaders(context);
FILE *stream;
char *key;
char *val;
HashMap *response;
char *key;
char *requestPath;
char *requestPathCpy;
MATRIX_PATH *pathParts;
char *pathPart;
RouteArgs routeArgs;
@ -60,14 +56,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
requestPath);
LogConfigIndent(lc);
Log(lc, LOG_DEBUG, "Request headers:");
LogConfigIndent(lc);
while (HashMapIterate(requestHeaders, &key, (void **) &val))
{
Log(lc, LOG_DEBUG, "%s: %s", key, val);
}
LogConfigUnindent(lc);
HttpResponseStatus(context, HTTP_OK);
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
@ -94,7 +82,8 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
}
pathParts = MATRIX_PATH_CREATE();
key = requestPath;
requestPathCpy = UtilStringDuplicate(requestPath);
key = requestPathCpy;
while ((pathPart = strtok_r(key, "/", &key)))
{
@ -103,6 +92,8 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
MATRIX_PATH_APPEND(pathParts, decoded);
}
Free(requestPathCpy);
routeArgs.matrixArgs = args;
routeArgs.context = context;
routeArgs.path = pathParts;
@ -127,7 +118,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
if (!response)
{
Log(lc, LOG_ERR, "A route handler returned NULL.");
Log(lc, LOG_ERR, "The route handler returned NULL: %s", requestPath);
HttpResponseStatus(context, HTTP_INTERNAL_SERVER_ERROR);
response = MatrixErrorCreate(M_UNKNOWN);
}