cs-3516-assignment-1/common/socket_helper.h

31 lines
939 B
C

#ifndef SOCKET_HELPER_H
#define SOCKET_HELPER_H
#include "http_types.h"
#define MIN_PORT 1
#define MAX_PORT 65535
#define BUFFER_SIZE 1024
#define HEADER_CONTENT_LENGTH "Content-Length"
#define HEADER_TRANSFER_ENCODING "Transfer-Encoding"
#define HEADER_CONNECTION "Connection"
#define HEADER_DATE "Date"
enum line_type {RESULT_START_LINE, RESULT_HEADER, RESULT_BLANK_LINE, RESULT_NO_LINE};
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 {
enum line_type line_type;
char *line;
int bytes_read;
};
struct socket_read_info {
enum socket_read_strategy strategy;
long length;
};
enum socket_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message);
#endif