]> Nishi Git Mirror - libw3.git/commitdiff
a
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 20 Jan 2024 17:57:03 +0000 (17:57 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Sat, 20 Jan 2024 17:57:03 +0000 (17:57 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@36 d27a3e52-49c5-7645-884c-6793ebffc270

Library/HTTP.c

index 11f7e91f842be78626cf69966165f95064d5e30d..cf211d3d11ba67655f781e0aef7b5990d07c316c 100644 (file)
@@ -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);
+                                       }
+                               }
                        }
                }
        }