static int parse_http_request(char *buf, int len, struct mg_request_info *ri) { int result = parse_http_message(buf, len, ri); if (result > 0 && is_valid_http_method(ri->request_method) && !strncmp(ri->http_version, "HTTP/", 5)) { ri->http_version += 5; // Skip "HTTP/" } else { result = -1; } return result; }
// Parse HTTP request, fill in mg_request_info structure. static int parse_http_request(char *buf, struct mg_request_info *ri) { int status = 0; // RFC says that all initial whitespaces should be ingored while (*buf != '\0' && isspace(* (unsigned char *) buf)) { buf++; } ri->request_method = skip(&buf, " "); ri->uri = skip(&buf, " "); ri->http_version = skip(&buf, "\r\n"); if (is_valid_http_method(ri->request_method) && strncmp(ri->http_version, "HTTP/", 5) == 0) { ri->http_version += 5; /* Skip "HTTP/" */ parse_http_headers(&buf, ri); status = 1; } return status; }