| 345 | } |
| 346 | |
| 347 | int phr_parse_request(const char *buf_start, size_t len, const char **method, |
| 348 | size_t *method_len, const char **path, size_t *path_len, |
| 349 | int *minor_version, struct phr_header *headers, |
| 350 | size_t *num_headers, size_t last_len) { |
| 351 | const char *buf = buf_start, *buf_end = buf_start + len; |
| 352 | size_t max_headers = *num_headers; |
| 353 | int r; |
| 354 | |
| 355 | *method = NULL; |
| 356 | *method_len = 0; |
| 357 | *path = NULL; |
| 358 | *path_len = 0; |
| 359 | *minor_version = -1; |
| 360 | *num_headers = 0; |
| 361 | |
| 362 | /* if last_len != 0, check if the request is complete (a fast countermeasure |
| 363 | againt slowloris */ |
| 364 | if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) { |
| 365 | return r; |
| 366 | } |
| 367 | |
| 368 | if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, |
| 369 | minor_version, headers, num_headers, max_headers, |
| 370 | &r)) == NULL) { |
| 371 | return r; |
| 372 | } |
| 373 | |
| 374 | return (int)(buf - buf_start); |
| 375 | } |
| 376 | |
| 377 | static const char *parse_response(const char *buf, const char *buf_end, |
| 378 | int *minor_version, int *status, |
no test coverage detected