From 2689e72f5e6d33e5b7d86d6595734cfaa22f083e Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Thu, 23 Oct 2025 20:56:52 +0200 Subject: [PATCH] add AQCGI_Request_Get/Set/Add/DelFlags() --- src/aqcgi/0BUILD | 2 +- src/aqcgi/request.c | 40 ++++++++++++++++++++++++++++++++++++++-- src/aqcgi/request.h | 13 ++++++++++++- src/aqcgi/request_p.h | 3 ++- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/aqcgi/0BUILD b/src/aqcgi/0BUILD index 8b78e27..d725606 100644 --- a/src/aqcgi/0BUILD +++ b/src/aqcgi/0BUILD @@ -63,7 +63,7 @@ - + api.h cgi.h request.h diff --git a/src/aqcgi/request.c b/src/aqcgi/request.c index 77af71f..36adb05 100644 --- a/src/aqcgi/request.c +++ b/src/aqcgi/request.c @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqCGI. - * AqCGI (c) by 2024 Martin Preuss, all rights reserved. + * AqCGI (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -65,7 +65,9 @@ GWEN_BUFFER *AQCGI_Request_GetBufferResponseHeader(const AQCGI_REQUEST *rq) void AQCGI_Request_AddResponseHeaderData(AQCGI_REQUEST *rq, const char *s) { if (rq && s && *s) { - GWEN_Buffer_AppendString(rq->bufferResponseHeader, s); + GWEN_Buffer_AppendArgs(rq->bufferResponseHeader, "%s\n", s); + if (strncasecmp(s, "Content-type:", 13)==0) + rq->flags|=AQCGI_FLAGS_HAS_CONTENT_HEADER; } } @@ -261,5 +263,39 @@ void AQCGI_Request_SetResponseRedirect(AQCGI_REQUEST *rq, const char *s) +uint32_t AQCGI_Request_GetFlags(const AQCGI_REQUEST *rq) +{ + return rq?(rq->flags):0; +} + + + +void AQCGI_Request_SetFlags(AQCGI_REQUEST *rq, uint32_t f) +{ + if (rq) + rq->flags=f; +} + + + +void AQCGI_Request_AddFlags(AQCGI_REQUEST *rq, uint32_t f) +{ + if (rq) + rq->flags|=f; +} + + + +void AQCGI_Request_SubFlags(AQCGI_REQUEST *rq, uint32_t f) +{ + if (rq) + rq->flags&=~f; +} + + + + + + diff --git a/src/aqcgi/request.h b/src/aqcgi/request.h index dd49da5..7433541 100644 --- a/src/aqcgi/request.h +++ b/src/aqcgi/request.h @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqCGI. - * AqCGI (c) by 2024 Martin Preuss, all rights reserved. + * AqCGI (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -17,6 +17,10 @@ #include +#define AQCGI_FLAGS_HAS_CONTENT_HEADER 0x0001 + + + enum { AQCGI_REQUEST_METHOD_GET=0, AQCGI_REQUEST_METHOD_POST @@ -69,4 +73,11 @@ AQCGI_API const char *AQCGI_Request_GetResponseRedirect(const AQCGI_REQUEST *rq) AQCGI_API void AQCGI_Request_SetResponseRedirect(AQCGI_REQUEST *rq, const char *s); +AQCGI_API uint32_t AQCGI_Request_GetFlags(const AQCGI_REQUEST *rq); +AQCGI_API void AQCGI_Request_SetFlags(AQCGI_REQUEST *rq, uint32_t f); +AQCGI_API void AQCGI_Request_AddFlags(AQCGI_REQUEST *rq, uint32_t f); +AQCGI_API void AQCGI_Request_SubFlags(AQCGI_REQUEST *rq, uint32_t f); + + + #endif diff --git a/src/aqcgi/request_p.h b/src/aqcgi/request_p.h index 63441a2..37c302d 100644 --- a/src/aqcgi/request_p.h +++ b/src/aqcgi/request_p.h @@ -1,6 +1,6 @@ /**************************************************************************** * This file is part of the project AqCGI. - * AqCGI (c) by 2024 Martin Preuss, all rights reserved. + * AqCGI (c) by 2025 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. @@ -30,6 +30,7 @@ struct AQCGI_REQUEST { char *responseText; char *responseRedirect; + uint32_t flags; };