summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-05-30 14:54:25 +0200
committerAki <please@ignore.pl>2020-05-30 15:13:25 +0200
commitb95df8445bec1e88ec686cd2c03cc48c6bae3c70 (patch)
tree0ec16a6d5aad6c66e31f4a175ca91f66dd1645bb
parent794d912cd7e05d3d97303e2578439362685edfcb (diff)
downloadplop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.zip
plop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.tar.gz
plop-b95df8445bec1e88ec686cd2c03cc48c6bae3c70.tar.bz2
Refactored read_rest_of_line
-rw-r--r--http.c12
1 files 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;
}