feat: only memmove read buffer on read

This commit is contained in:
Jef Roosens 2023-05-25 14:28:53 +02:00 committed by Chewing_Bever
parent c58e53eb2a
commit 32687e0b49
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 37 additions and 29 deletions

View file

@ -4,16 +4,17 @@
/*
* given the HTTP path, parse the request
*/
http_parse_error http_parse_request(http_request *req, const char *buf, size_t buf_size) {
http_parse_error http_parse_request(http_request *req, const char *buf,
size_t buf_size) {
// First we try to parse the incoming HTTP request
const char *method, *path;
struct phr_header headers[16];
size_t method_len, path_len, num_headers;
int minor_version;
int res = phr_parse_request(buf, buf_size,
&method, &method_len, &path, &path_len,
&minor_version, headers, &num_headers, 0);
int res =
phr_parse_request(buf, buf_size, &method, &method_len, &path, &path_len,
&minor_version, headers, &num_headers, 0);
if (res == -2) {
return http_parse_error_incomplete;