From 562816c15f2b3019ebe515cd8ed58358f1c4291d Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 20 Jan 2024 17:57:03 +0000 Subject: [PATCH] a git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@36 d27a3e52-49c5-7645-884c-6793ebffc270 --- Library/HTTP.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Library/HTTP.c b/Library/HTTP.c index 11f7e91..cf211d3 100644 --- a/Library/HTTP.c +++ b/Library/HTTP.c @@ -83,7 +83,6 @@ void __W3_HTTP_Request(struct W3* w3){ } } phase++; - break; }else{ char* oldbuf = statusbuf; statusbuf = malloc(strlen(oldbuf) + 2); @@ -99,6 +98,36 @@ void __W3_HTTP_Request(struct W3* w3){ headerbuf[strlen(oldbuf)] = buf[i]; headerbuf[strlen(oldbuf) + 1] = 0; free(oldbuf); + int len = strlen(headerbuf); + if(len >= 4){ + if(headerbuf[len - 1] == '\n' && headerbuf[len - 2] == '\r' && headerbuf[len - 3] == '\n' && headerbuf[len - 4] == '\r'){ + headerbuf[len - 4] = 0; + char* headers = malloc(strlen(headerbuf) + 1); + int j; + int incr = 0; + int start = 0; + for(j = 1; headerbuf[j] != 0; j++){ + char c = headerbuf[j]; + if(c == '\r'){ + headers[incr] = 0; + headers[incr + 1] = 0; + char* data = __W3_Strdup(headers + start); + int k; + for(k = 0; data[k] != 0; k++){ + } + free(data); + start = incr + 1; + incr++; + j++; + }else{ + headers[incr] = c; + headers[incr + 1] = 0; + incr++; + } + } + free(headers); + } + } } } } -- 2.43.0