From 5353e35e5863881b55680425133d19a60fe67852 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Mon, 3 Sep 2018 15:03:37 -0400 Subject: [PATCH] Add missing doc comments --- common/socket_helper.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/socket_helper.c b/common/socket_helper.c index 54d771b..f0fc2da 100644 --- a/common/socket_helper.c +++ b/common/socket_helper.c @@ -116,6 +116,14 @@ static struct socket_read_info get_read_info(const struct http_header *headers) return info; } +/** + * Reads a socket based on a given content_length, usually from a Content-Length header. + * + * @param socket_fd The file descriptor of the socket. + * @param content_length The content length to read from the socket. + * + * @return The content in the socket. Must be freed by the caller. + */ static char *read_body_by_content_length(int socket_fd, int content_length) { char *result = malloc((content_length + 1) * sizeof(char)); char *buffer = malloc(content_length * sizeof(char)); @@ -136,6 +144,13 @@ static char *read_body_by_content_length(int socket_fd, int content_length) { return result; } +/** + * Reads a socket until EOF + * + * @param socket_fd The file descriptor of the socket. + * + * @return The content in the socket. Must be freed by caller. + */ static char *read_body_until_eof(int socket_fd) { ssize_t current_result_size = 0; int write_offset = 0; @@ -159,6 +174,15 @@ static char *read_body_until_eof(int socket_fd) { return result; } +/** + * Gets all remote pieces of a given socket. + * + * @param socket_fd The socket file descriptor. + * @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. + */ enum socket_read_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;