From b95df8445bec1e88ec686cd2c03cc48c6bae3c70 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 30 May 2020 14:54:25 +0200 Subject: Refactored read_rest_of_line --- http.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/http.c b/http.c index ca7dcdf..5e1472c 100644 --- a/http.c +++ b/http.c @@ -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; } -- cgit v1.1