diff options
author | Aki <please@ignore.pl> | 2020-05-30 14:54:25 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2020-05-30 15:13:25 +0200 |
commit | b95df8445bec1e88ec686cd2c03cc48c6bae3c70 (patch) | |
tree | 0ec16a6d5aad6c66e31f4a175ca91f66dd1645bb | |
parent | 794d912cd7e05d3d97303e2578439362685edfcb (diff) | |
download | plop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.zip plop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.tar.gz plop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.tar.bz2 |
Refactored read_rest_of_line
-rw-r--r-- | http.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -173,20 +173,20 @@ static int read_until_word(struct request * request) /// \return Position of the first byte of the separator or 0 if line separator could not be found static int read_rest_of_line(struct request * request) { - char buffer[2] = {0, 0}; while (request->position < request->length - 1) { - memcpy(buffer, &request->data[request->position], 2); - if (0 == strncmp(buffer, "\r\n", 2)) + if ('\r' == request->data[request->position] && '\n' == request->data[request->position + 1]) { return request->position; } - if (buffer[1] == '\r') + else if ('\r' == request->data[request->position + 1]) { request->position += 1; - continue; } - request->position += 2; + else + { + request->position += 2; + } } return 0; } |