505 before a 405

master
Nick Krichevsky 2018-09-11 17:23:29 -04:00
parent 10acd72f28
commit 6e66c46383
1 changed files with 4 additions and 4 deletions

View File

@ -203,10 +203,10 @@ static enum request_parse_result parse_and_validate_request(struct http_message
int parse_result = parse_request_line(message.start_line, req_line);
if (parse_result == -1) {
return PARSE_RESULT_MALFORMED;
} else if (strcmp(req_line->method, "GET") != 0) {
return PARSE_RESULT_BAD_METHOD;
} else if (strcmp(req_line->http_version, HTTP_VERSION) != 0) {
return PARSE_RESULT_BAD_VERSION;
} else if (strcmp(req_line->method, "GET") != 0) {
return PARSE_RESULT_BAD_METHOD;
}
return PARSE_RESULT_OK;
@ -256,10 +256,10 @@ enum socket_result serve_one_request(int sock_fd) {
int status_code = 500;
if (parse_result == PARSE_RESULT_MALFORMED) {
status_code = 400;
} else if (parse_result == PARSE_RESULT_BAD_METHOD) {
status_code = 405;
} else if (parse_result == PARSE_RESULT_BAD_VERSION) {
status_code = 505;
} else if (parse_result == PARSE_RESULT_BAD_METHOD) {
status_code = 405;
}
send_headers(status_code, client_fd, -1);
free_request_line_items(&parsed_request_line);