From cf1d164ec51077f8879ca2ccc2485e3cf9c18cc6 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Sun, 9 Sep 2018 00:18:56 -0400 Subject: [PATCH] Rename socket_read_result to socket_result --- client/http_client.c | 2 +- client/http_socket.c | 6 +++--- client/http_socket.h | 2 +- common/socket_helper.c | 4 ++-- common/socket_helper.h | 4 ++-- server/socket_server.c | 2 +- server/socket_server.h | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/http_client.c b/client/http_client.c index eb6949a..f62ebbd 100644 --- a/client/http_client.c +++ b/client/http_client.c @@ -29,7 +29,7 @@ int main(int argc, char* argv[]) { get_parts(dest, path_buffer, host_buffer); struct http_message req = build_basic_request("GET", host_buffer, path_buffer, port_num); struct response_info res; - enum socket_read_result read_result = send_request(req, &res); + enum socket_result read_result = send_request(req, &res); if (read_result != RESULT_OK) { printf("An error occured while opening the socket. Please try again.\n"); } else { diff --git a/client/http_socket.c b/client/http_socket.c index ccdd971..68f3179 100644 --- a/client/http_socket.c +++ b/client/http_socket.c @@ -106,9 +106,9 @@ static long long get_rtt(struct timeval pre_connect_time, struct timeval post_co * @param req The HTTP request to send * @param res_info A pointer to an already allocated response_info. res_info.contents must be freed by the caller. * - * @return A socket_read_result representing the status of the response. + * @return A socket_result representing the status of the response. */ -enum socket_read_result send_request(struct http_message req, struct response_info *res_info) { +enum socket_result send_request(struct http_message req, struct response_info *res_info) { struct addrinfo *addr_info; int addr_status = build_addr_info(req.address, req.port, &addr_info); if (addr_status != 0) { @@ -149,7 +149,7 @@ enum socket_read_result send_request(struct http_message req, struct response_in // Send and process the request. send(socket_fd, req.contents, strlen(req.contents), 0); struct http_message res = {}; - enum socket_read_result result = get_all_remote_parts(socket_fd, TYPE_CLIENT, &res); + enum socket_result result = get_all_remote_parts(socket_fd, TYPE_CLIENT, &res); res_info->contents = res.contents; close(socket_fd); free(res.start_line); diff --git a/client/http_socket.h b/client/http_socket.h index bc58468..9c0b7cc 100644 --- a/client/http_socket.h +++ b/client/http_socket.h @@ -14,6 +14,6 @@ struct response_info { struct http_message build_basic_request(const char *method, const char *host, const char *path, int port); void free_basic_request(struct http_message req); -enum socket_read_result send_request(struct http_message req, struct response_info *res_info); +enum socket_result send_request(struct http_message req, struct response_info *res_info); #endif diff --git a/common/socket_helper.c b/common/socket_helper.c index f9ffa64..35d3950 100644 --- a/common/socket_helper.c +++ b/common/socket_helper.c @@ -182,9 +182,9 @@ static char *read_body_until_eof(int socket_fd) { * @param type An indication of this socket is for a client or a server * @param message A http_message to store the output in. * - * @return A socket_read_result indicating the result of the read. + * @return A socket_result indicating the result of the read. */ -enum socket_read_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message) { +enum socket_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message) { ssize_t current_result_size = 0; char *result = NULL; char *buffer = malloc(BUFFER_SIZE * sizeof(char)); diff --git a/common/socket_helper.h b/common/socket_helper.h index 2f89bdb..12ea677 100644 --- a/common/socket_helper.h +++ b/common/socket_helper.h @@ -10,7 +10,7 @@ #define HEADER_TRANSFER_ENCODING "Transfer-Encoding" enum line_type {RESULT_START_LINE, RESULT_HEADER, RESULT_BLANK_LINE, RESULT_NO_LINE}; -enum socket_read_result {RESULT_OK, RESULT_MALFORMED, RESULT_READ_ERROR, RESULT_PROCESSING_ERROR, RESULT_WRITE_ERROR}; +enum socket_result {RESULT_OK, RESULT_MALFORMED, RESULT_READ_ERROR, RESULT_PROCESSING_ERROR, RESULT_WRITE_ERROR}; enum socket_read_strategy {STRATEGY_CONTENT_LENGTH, STRATEGY_EOF, STRATEGY_UNDEFINED}; enum socket_type {TYPE_CLIENT, TYPE_SERVER}; struct line_read_result { @@ -24,6 +24,6 @@ struct socket_read_info { long length; }; -enum socket_read_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message); +enum socket_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message); #endif diff --git a/server/socket_server.c b/server/socket_server.c index ffdad4b..a69bf02 100644 --- a/server/socket_server.c +++ b/server/socket_server.c @@ -71,7 +71,7 @@ struct server_info setup(int port) { return info; } -enum socket_read_result serve_one_request(int sock_fd) { +enum socket_result serve_one_request(int sock_fd) { int client_fd = accept(sock_fd, NULL, NULL); if (client_fd == -1) { return RESULT_WRITE_ERROR; diff --git a/server/socket_server.h b/server/socket_server.h index 4504c4a..02f8012 100644 --- a/server/socket_server.h +++ b/server/socket_server.h @@ -12,6 +12,6 @@ struct server_info { }; struct server_info setup(int port); -enum socket_read_result serve_one_request(int sock_fd); +enum socket_result serve_one_request(int sock_fd); #endif