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

31 lines
939 B
C
Raw Normal View History

#ifndef SOCKET_HELPER_H
#define SOCKET_HELPER_H
#include "http_types.h"
2018-09-03 22:54:02 +00:00
#define MIN_PORT 1
#define MAX_PORT 65535
#define BUFFER_SIZE 1024
2018-09-02 00:29:04 +00:00
#define HEADER_CONTENT_LENGTH "Content-Length"
#define HEADER_TRANSFER_ENCODING "Transfer-Encoding"
2018-09-09 21:34:26 +00:00
#define HEADER_CONNECTION "Connection"
2018-09-11 01:24:28 +00:00
#define HEADER_DATE "Date"
2018-09-01 20:22:08 +00:00
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};
2018-09-06 13:06:41 +00:00
enum socket_read_strategy {STRATEGY_CONTENT_LENGTH, STRATEGY_EOF, STRATEGY_UNDEFINED};
enum socket_type {TYPE_CLIENT, TYPE_SERVER};
2018-09-01 20:22:08 +00:00
struct line_read_result {
enum line_type line_type;
char *line;
int bytes_read;
};
2018-09-02 00:29:04 +00:00
struct socket_read_info {
enum socket_read_strategy strategy;
2018-09-03 20:41:00 +00:00
long length;
2018-09-02 00:29:04 +00:00
};
2018-09-01 20:22:08 +00:00
enum socket_result get_all_remote_parts(int socket_fd, enum socket_type type, struct http_message *message);
#endif