forked from Telodendria/Telodendria
Remove some debug statements; make route error more specific.
This commit is contained in:
parent
e37e6f1bb8
commit
5080d066ab
2 changed files with 20 additions and 23 deletions
|
@ -32,8 +32,14 @@ as well, so you can discuss your progress and ask questions.
|
||||||
.Pp
|
.Pp
|
||||||
Not released yet.
|
Not released yet.
|
||||||
.Pp
|
.Pp
|
||||||
.Nm
|
Changes:
|
||||||
homeserver changes and fixes:
|
.Bl -bullet
|
||||||
|
.It
|
||||||
|
Improved HTTP request logging by removing unnecessary
|
||||||
|
log entries and making errors more specific.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
Bug fixes:
|
||||||
.Pp
|
.Pp
|
||||||
.Bl -bullet
|
.Bl -bullet
|
||||||
.It
|
.It
|
||||||
|
@ -41,18 +47,18 @@ Fixed a memory leak that would occur when parsing an invalid
|
||||||
JSON object.
|
JSON object.
|
||||||
.It
|
.It
|
||||||
Fixed an edge case where HTTP response headers were being
|
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
|
report a status of 200 even when that wasn't the desired
|
||||||
status.
|
status.
|
||||||
.It
|
.It
|
||||||
Fixed a few memory leaks in the HTTP parameter decoder that
|
Fixed a few memory leaks in the HTTP parameter decoder that
|
||||||
would occur in some edge cases.
|
would occur in some edge cases.
|
||||||
.It
|
.It
|
||||||
Fixed an "off-by-one" error in the HTTP server that
|
Fixed an "off-by-one" error in the HTTP server request
|
||||||
prevented GET parameters from being parsed.
|
parser that prevented GET parameters from being parsed.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Other changes and fixes included in this release:
|
Misc.:
|
||||||
.Bl -bullet
|
.Bl -bullet
|
||||||
.It
|
.It
|
||||||
Fixed a bug in
|
Fixed a bug in
|
||||||
|
|
25
src/Matrix.c
25
src/Matrix.c
|
@ -37,18 +37,14 @@ void
|
||||||
MatrixHttpHandler(HttpServerContext * context, void *argp)
|
MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
{
|
{
|
||||||
MatrixHttpHandlerArgs *args = (MatrixHttpHandlerArgs *) argp;
|
MatrixHttpHandlerArgs *args = (MatrixHttpHandlerArgs *) argp;
|
||||||
|
|
||||||
LogConfig *lc = args->lc;
|
LogConfig *lc = args->lc;
|
||||||
|
|
||||||
HashMap *requestHeaders = HttpRequestHeaders(context);
|
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
|
|
||||||
char *key;
|
|
||||||
char *val;
|
|
||||||
|
|
||||||
HashMap *response;
|
HashMap *response;
|
||||||
|
|
||||||
|
char *key;
|
||||||
|
|
||||||
char *requestPath;
|
char *requestPath;
|
||||||
|
char *requestPathCpy;
|
||||||
MATRIX_PATH *pathParts;
|
MATRIX_PATH *pathParts;
|
||||||
char *pathPart;
|
char *pathPart;
|
||||||
RouteArgs routeArgs;
|
RouteArgs routeArgs;
|
||||||
|
@ -60,14 +56,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
requestPath);
|
requestPath);
|
||||||
|
|
||||||
LogConfigIndent(lc);
|
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);
|
HttpResponseStatus(context, HTTP_OK);
|
||||||
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
|
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
|
||||||
|
@ -94,7 +82,8 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pathParts = MATRIX_PATH_CREATE();
|
pathParts = MATRIX_PATH_CREATE();
|
||||||
key = requestPath;
|
requestPathCpy = UtilStringDuplicate(requestPath);
|
||||||
|
key = requestPathCpy;
|
||||||
|
|
||||||
while ((pathPart = strtok_r(key, "/", &key)))
|
while ((pathPart = strtok_r(key, "/", &key)))
|
||||||
{
|
{
|
||||||
|
@ -103,6 +92,8 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
MATRIX_PATH_APPEND(pathParts, decoded);
|
MATRIX_PATH_APPEND(pathParts, decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Free(requestPathCpy);
|
||||||
|
|
||||||
routeArgs.matrixArgs = args;
|
routeArgs.matrixArgs = args;
|
||||||
routeArgs.context = context;
|
routeArgs.context = context;
|
||||||
routeArgs.path = pathParts;
|
routeArgs.path = pathParts;
|
||||||
|
@ -127,7 +118,7 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
|
|
||||||
if (!response)
|
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);
|
HttpResponseStatus(context, HTTP_INTERNAL_SERVER_ERROR);
|
||||||
response = MatrixErrorCreate(M_UNKNOWN);
|
response = MatrixErrorCreate(M_UNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue