92 lines
1.3 KiB
C
92 lines
1.3 KiB
C
|
|
#ifndef _http
|
||
|
|
|
||
|
|
#define _http
|
||
|
|
|
||
|
|
|
||
|
|
// Macros
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#include "stdlib.h"
|
||
|
|
|
||
|
|
extern char * __ClassNames[];
|
||
|
|
|
||
|
|
|
||
|
|
// Includes
|
||
|
|
|
||
|
|
#include <sys/resource.h>
|
||
|
|
|
||
|
|
#include <openssl/ssl.h>
|
||
|
|
|
||
|
|
#include <openssl/err.h>
|
||
|
|
|
||
|
|
#include <headers.h>
|
||
|
|
|
||
|
|
#include <request.h>
|
||
|
|
|
||
|
|
#include <unistd.h>
|
||
|
|
|
||
|
|
#include <sys/socket.h>
|
||
|
|
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
#include <errno.h>
|
||
|
|
|
||
|
|
#include <arpa/inet.h>
|
||
|
|
|
||
|
|
#include "./mimeTypes.h"
|
||
|
|
|
||
|
|
#include "./text.h"
|
||
|
|
|
||
|
|
#include "./fileSystem.h"
|
||
|
|
|
||
|
|
|
||
|
|
typedef struct http{
|
||
|
|
|
||
|
|
unsigned short __classIndex;
|
||
|
|
|
||
|
|
int socket;
|
||
|
|
|
||
|
|
struct sockaddr_in * hostAddress;
|
||
|
|
|
||
|
|
int hostAddresslength;
|
||
|
|
|
||
|
|
struct fileSystem * filesystem;
|
||
|
|
|
||
|
|
struct mimeTypes * mimetypes;
|
||
|
|
|
||
|
|
struct headerManager * headers;
|
||
|
|
|
||
|
|
int useSSL;
|
||
|
|
|
||
|
|
SSL_CTX * sslContext;
|
||
|
|
|
||
|
|
void ( * requestCallback )( struct request * requestInstance, struct text * response );
|
||
|
|
|
||
|
|
|
||
|
|
} http;
|
||
|
|
|
||
|
|
void http_createServer( http * this, void ( * requestCallback )( request * req, text * response ) );
|
||
|
|
|
||
|
|
void http_initializeOpenSSL( http * this );
|
||
|
|
|
||
|
|
int http_listen( http * this, int port );
|
||
|
|
|
||
|
|
char * http_getExtension( http * this, char * path );
|
||
|
|
|
||
|
|
void http_logRequest( http * this, request * requestInstance );
|
||
|
|
|
||
|
|
void http_acceptConnection( http * this );
|
||
|
|
|
||
|
|
void http_dump_buffer( http * this, void *buffer, int buffer_size );
|
||
|
|
|
||
|
|
void abort( );
|
||
|
|
|
||
|
|
http http_new( );
|
||
|
|
|
||
|
|
http * http_newPointer( );
|
||
|
|
|
||
|
|
#endif
|