From 6e66c46383c8ee0dba0f4b75e7050e3f3431d44a Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Tue, 11 Sep 2018 17:23:29 -0400 Subject: [PATCH] 505 before a 405 --- server/socket_server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/socket_server.c b/server/socket_server.c index 0921a64..e4b1cbc 100644 --- a/server/socket_server.c +++ b/server/socket_server.c @@ -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);