Commit cf18c932 authored by Sergey Lyubka's avatar Sergey Lyubka

Refactored parse_http_message()

parent a730afc4
......@@ -3060,8 +3060,11 @@ static int parse_http_message(char *buf, int len, struct mg_request_info *ri) {
ri->request_method = skip(&buf, " ");
ri->uri = skip(&buf, " ");
ri->http_version = skip(&buf, "\r\n");
if (((is_request = is_valid_http_method(ri->request_method)) &&
memcmp(ri->http_version, "HTTP/", 5) != 0) ||
// HTTP message could be either HTTP request or HTTP response, e.g.
// "GET / HTTP/1.0 ...." or "HTTP/1.0 200 OK ..."
is_request = is_valid_http_method(ri->request_method);
if ((is_request && memcmp(ri->http_version, "HTTP/", 5) != 0) ||
(!is_request && memcmp(ri->request_method, "HTTP/", 5)) != 0) {
request_length = -1;
} else {
......
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