Log once we get the response status, not right when we get the request.

This commit is contained in:
Jordan Bancino 2023-03-22 18:13:59 +00:00
parent fccd15b239
commit 9ec330f40a
4 changed files with 22 additions and 4 deletions

View file

@ -233,6 +233,17 @@ HttpResponseStatus(HttpServerContext * c, HttpStatus status)
c->responseStatus = status;
}
HttpStatus
HttpResponseStatusGet(HttpServerContext *c)
{
if (!c)
{
return HTTP_STATUS_UNKNOWN;
}
return c->responseStatus;
}
Stream *
HttpServerStream(HttpServerContext * c)
{

View file

@ -51,10 +51,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
requestPath = HttpRequestPath(context);
Log(LOG_INFO, "%s %s",
HttpRequestMethodToString(HttpRequestMethodGet(context)),
requestPath);
HttpResponseStatus(context, HTTP_OK);
HttpResponseHeader(context, "Server", "Telodendria/" TELODENDRIA_VERSION);
@ -143,6 +139,12 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
}
MATRIX_PATH_FREE(pathParts);
Log(LOG_INFO, "%s %s (%d %s)",
HttpRequestMethodToString(HttpRequestMethodGet(context)),
requestPath,
HttpResponseStatusGet(context),
HttpStatusToString(HttpResponseStatusGet(context)));
}
HashMap *

View file

@ -48,6 +48,8 @@ typedef enum HttpRequestMethod
typedef enum HttpStatus
{
HTTP_STATUS_UNKNOWN = 0,
/* Informational responses */
HTTP_CONTINUE = 100,
HTTP_SWITCHING_PROTOCOLS = 101,

View file

@ -69,6 +69,9 @@ extern char *
extern void
HttpResponseStatus(HttpServerContext *, HttpStatus);
extern HttpStatus
HttpResponseStatusGet(HttpServerContext *);
extern Stream *
HttpServerStream(HttpServerContext *);