Commit 2055d41a authored by Sergey Lyubka's avatar Sergey Lyubka

Corrected misplaced brackets in parse_http_message()

parent 1ef29c1b
...@@ -3070,7 +3070,7 @@ static int parse_http_message(char *buf, int len, struct mg_request_info *ri) { ...@@ -3070,7 +3070,7 @@ static int parse_http_message(char *buf, int len, struct mg_request_info *ri) {
// "GET / HTTP/1.0 ...." or "HTTP/1.0 200 OK ..." // "GET / HTTP/1.0 ...." or "HTTP/1.0 200 OK ..."
is_request = is_valid_http_method(ri->request_method); is_request = is_valid_http_method(ri->request_method);
if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) || if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) ||
(!is_request && memcmp(ri->request_method, "HTTP/", 5)) != 0) { (!is_request && memcmp(ri->request_method, "HTTP/", 5) != 0)) {
request_length = -1; request_length = -1;
} else { } else {
if (is_request) { if (is_request) {
......
...@@ -63,6 +63,10 @@ static void test_parse_http_message() { ...@@ -63,6 +63,10 @@ static void test_parse_http_message() {
char req6[] = "G"; char req6[] = "G";
char req7[] = " blah "; char req7[] = " blah ";
char req8[] = " HTTP/1.1 200 OK \n\n"; char req8[] = " HTTP/1.1 200 OK \n\n";
char req9[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n";
ASSERT(parse_http_message(req9, sizeof(req9), &ri) == sizeof(req9) - 1);
ASSERT(ri.num_headers == 1);
ASSERT(parse_http_message(req1, sizeof(req1), &ri) == sizeof(req1) - 1); ASSERT(parse_http_message(req1, sizeof(req1), &ri) == sizeof(req1) - 1);
ASSERT(strcmp(ri.http_version, "1.1") == 0); ASSERT(strcmp(ri.http_version, "1.1") == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment