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; c->responseStatus = status;
} }
HttpStatus
HttpResponseStatusGet(HttpServerContext *c)
{
if (!c)
{
return HTTP_STATUS_UNKNOWN;
}
return c->responseStatus;
}
Stream * Stream *
HttpServerStream(HttpServerContext * c) HttpServerStream(HttpServerContext * c)
{ {

View file

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

View file

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

View file

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