From 64d58d0c5a01551f8bfc52291986d1b8d681aca5 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Mon, 3 Feb 2025 22:18:58 +0000 Subject: New upstream version 6.0.24.59a+repack --- HTTPcode.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'HTTPcode.c') diff --git a/HTTPcode.c b/HTTPcode.c index 2c0a8dd..54a0614 100644 --- a/HTTPcode.c +++ b/HTTPcode.c @@ -24,7 +24,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses #define DllImport -#include "CHeaders.h" +#include "cheaders.h" #include #include "tncinfo.h" @@ -70,6 +70,7 @@ char * GetStandardPage(char * FN, int * Len); BOOL SHA1PasswordHash(char * String, char * Hash); char * byte_base64_encode(char *str, int len); int APIProcessHTTPMessage(char * response, char * Method, char * URL, char * request, BOOL LOCAL, BOOL COOKIE); +int RHPProcessHTTPMessage(struct ConnectionInfo * conn, char * response, char * Method, char * URL, char * request, BOOL LOCAL, BOOL COOKIE); extern struct ROUTE * NEIGHBOURS; extern int ROUTE_LEN; @@ -1852,6 +1853,43 @@ int InnerProcessHTTPMessage(struct ConnectionInfo * conn) } } + if (_memicmp(Context, "/rhp/", 5) == 0 || _stricmp(Context, "/rhp") == 0) + { + { + ReplyLen = RHPProcessHTTPMessage(conn, _REPLYBUFFER, Method, Context, MsgPtr, LOCAL, COOKIE); + + if (memcmp(_REPLYBUFFER, "HTTP", 4) == 0) + { + // Full Message - just send it + + sendandcheck(sock, _REPLYBUFFER, ReplyLen); + + return 0; + } + + if (allowDeflate) + Compressed = Compressit(_REPLYBUFFER, ReplyLen, &ReplyLen); + else + Compressed = _REPLYBUFFER; + + HeaderLen = sprintf(Header, "HTTP/1.1 200 OK\r\n" + "Content-Length: %d\r\n" + "Content-Type: application/json\r\n" + "Connection: close\r\n" + "Access-Control-Allow-Origin: *\r\n" + "%s\r\n", ReplyLen, Encoding); + + sendandcheck(sock, Header, HeaderLen); + sendandcheck(sock, Compressed, ReplyLen); + + if (allowDeflate) + free (Compressed); + + return 0; + } + } + + // APRS process internally if (_memicmp(Context, "/APRS/", 6) == 0 || _stricmp(Context, "/APRS") == 0) @@ -5135,6 +5173,3 @@ void SHA1PadMessage(SHA1Context *context) } - - - -- cgit v1.2.3