Changeset 20 in Main for trunk/Server/http.c
- Timestamp:
- Sep 14, 2024, 6:59:15 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/http.c
r17 r20 23 23 if(req->method != NULL) free(req->method); 24 24 if(req->path != NULL) free(req->path); 25 if(req->query != NULL) free(req->query); 25 26 if(req->headers != NULL) { 26 27 int i; … … 44 45 req->method = NULL; 45 46 req->path = NULL; 47 req->query = NULL; 46 48 req->headers = NULL; 47 49 req->body = NULL; … … 246 248 return 1; 247 249 } 250 char* result = malloc(1); 251 result[0] = 0; 252 int i; 253 for(i = 0; req->path[i] != 0; i++) { 254 if(req->path[i] == '?') { 255 req->path[i] = 0; 256 req->query = cm_strdup(req->path + i + 1); 257 break; 258 } 259 } 260 for(i = 0; req->path[i] != 0; i++) { 261 if(req->path[i] == '%') { 262 if(req->path[i + 1] == 0) continue; 263 cbuf[0] = cm_hex(req->path + i + 1, 2); 264 char* tmp = result; 265 result = cm_strcat(tmp, cbuf); 266 free(tmp); 267 i += 2; 268 } else { 269 cbuf[0] = req->path[i]; 270 char* tmp = result; 271 result = cm_strcat(tmp, cbuf); 272 free(tmp); 273 } 274 } 275 free(req->path); 276 req->path = result; 248 277 return 0; 249 278 }
Note:
See TracChangeset
for help on using the changeset viewer.