505 before a 405
parent
10acd72f28
commit
6e66c46383
|
@ -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);
|
int parse_result = parse_request_line(message.start_line, req_line);
|
||||||
if (parse_result == -1) {
|
if (parse_result == -1) {
|
||||||
return PARSE_RESULT_MALFORMED;
|
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) {
|
} else if (strcmp(req_line->http_version, HTTP_VERSION) != 0) {
|
||||||
return PARSE_RESULT_BAD_VERSION;
|
return PARSE_RESULT_BAD_VERSION;
|
||||||
|
} else if (strcmp(req_line->method, "GET") != 0) {
|
||||||
|
return PARSE_RESULT_BAD_METHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PARSE_RESULT_OK;
|
return PARSE_RESULT_OK;
|
||||||
|
@ -256,10 +256,10 @@ enum socket_result serve_one_request(int sock_fd) {
|
||||||
int status_code = 500;
|
int status_code = 500;
|
||||||
if (parse_result == PARSE_RESULT_MALFORMED) {
|
if (parse_result == PARSE_RESULT_MALFORMED) {
|
||||||
status_code = 400;
|
status_code = 400;
|
||||||
} else if (parse_result == PARSE_RESULT_BAD_METHOD) {
|
|
||||||
status_code = 405;
|
|
||||||
} else if (parse_result == PARSE_RESULT_BAD_VERSION) {
|
} else if (parse_result == PARSE_RESULT_BAD_VERSION) {
|
||||||
status_code = 505;
|
status_code = 505;
|
||||||
|
} else if (parse_result == PARSE_RESULT_BAD_METHOD) {
|
||||||
|
status_code = 405;
|
||||||
}
|
}
|
||||||
send_headers(status_code, client_fd, -1);
|
send_headers(status_code, client_fd, -1);
|
||||||
free_request_line_items(&parsed_request_line);
|
free_request_line_items(&parsed_request_line);
|
||||||
|
|
Loading…
Reference in New Issue