My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
connection-handler.c File Reference
#include "webserver/connection-handler.h"
#include "logging.h"
#include "webserver/sslops.h"
#include "webserver/socketops.h"
#include "webserver/dbops.h"
#include "webserver/regex.h"
#include "webserver/request_parser.h"
#include <unistd.h>

Go to the source code of this file.

Macros

#define UNUSED
 
#define REGEX_KEY   "regex="
 
#define MAX_REGEX_VALUE_LEN   64
 
#define DEFAULT_HTTP_HEADER   "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n" \
 
#define DEFAULT_HTTP_BODY   "<!DOCTYPE html>\n<html>\n<body>\n<h1>Dedos New Runtime</h1>\n</body>\n</html>"
 
#define ERROR_HTTP_HEADER   "HTTP/1.1 418 IM A TEAPOT\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n"
 
#define ERROR_HTTP_BODY   "<!DOCTYPE html>\n<html>\n<body>\n<h1>418 I am a teapot</h1>\n</body>\n</html>"
 

Functions

void init_connection (struct connection *conn, int fd)
 
void init_read_state (struct read_state *state, struct connection *conn)
 
void init_http_state (struct http_state *state, struct connection *conn)
 
void init_response_state (struct response_state *state, struct connection *conn)
 
int accept_connection (struct connection *conn, int use_ssl)
 
int read_request (struct read_state *state)
 
int parse_request (char *req, int req_len, struct http_state *state)
 
int has_regex (char *url)
 
static int get_regex_value (char *url, char *regex)
 
int access_database (char *url, struct db_state *state)
 
int craft_error_response (char *url, char *response)
 
int craft_nonregex_response (char *url, char *response)
 
int craft_regex_response (char *url, char *response)
 
int write_response (struct response_state *state)
 
int close_connection (struct connection *conn)
 

Macro Definition Documentation

#define DEFAULT_HTTP_BODY   "<!DOCTYPE html>\n<html>\n<body>\n<h1>Dedos New Runtime</h1>\n</body>\n</html>"

Definition at line 198 of file connection-handler.c.

#define DEFAULT_HTTP_HEADER   "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n" \

Definition at line 195 of file connection-handler.c.

#define ERROR_HTTP_BODY   "<!DOCTYPE html>\n<html>\n<body>\n<h1>418 I am a teapot</h1>\n</body>\n</html>"

Definition at line 204 of file connection-handler.c.

#define ERROR_HTTP_HEADER   "HTTP/1.1 418 IM A TEAPOT\r\nContent-Type: text/html\r\nContent-Length: %d\r\n\r\n"

Definition at line 201 of file connection-handler.c.

#define MAX_REGEX_VALUE_LEN   64

Definition at line 148 of file connection-handler.c.

#define REGEX_KEY   "regex="

Definition at line 136 of file connection-handler.c.

#define UNUSED

Definition at line 33 of file connection-handler.c.

Function Documentation

int accept_connection ( struct connection conn,
int  use_ssl 
)

Definition at line 64 of file connection-handler.c.

int access_database ( char *  url,
struct db_state state 
)

Definition at line 173 of file connection-handler.c.

int close_connection ( struct connection conn)

Definition at line 298 of file connection-handler.c.

int craft_error_response ( char *  url,
char *  response 
)

Definition at line 207 of file connection-handler.c.

int craft_nonregex_response ( char *  url,
char *  response 
)

Definition at line 213 of file connection-handler.c.

int craft_regex_response ( char *  url,
char *  response 
)

Definition at line 220 of file connection-handler.c.

static int get_regex_value ( char *  url,
char *  regex 
)
static

Definition at line 150 of file connection-handler.c.

int has_regex ( char *  url)

Definition at line 138 of file connection-handler.c.

void init_connection ( struct connection conn,
int  fd 
)

Definition at line 36 of file connection-handler.c.

void init_http_state ( struct http_state state,
struct connection conn 
)

Definition at line 48 of file connection-handler.c.

void init_read_state ( struct read_state state,
struct connection conn 
)

Definition at line 42 of file connection-handler.c.

void init_response_state ( struct response_state state,
struct connection conn 
)

Definition at line 54 of file connection-handler.c.

int parse_request ( char *  req,
int  req_len,
struct http_state state 
)

Definition at line 117 of file connection-handler.c.

int read_request ( struct read_state state)

Definition at line 87 of file connection-handler.c.

int write_response ( struct response_state state)

Definition at line 239 of file connection-handler.c.