|
|
|
#ifndef REQUEST_H
|
|
|
|
#define REQUEST_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "requestresponse.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A struct reperesenting an http request
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
// Common versions are: 0.9, 1.0, 1.1, 2.0
|
|
|
|
float version;
|
|
|
|
char *method;
|
|
|
|
char *protocol;
|
|
|
|
char *host;
|
|
|
|
char *path;
|
|
|
|
int port;
|
|
|
|
HeaderList *headers;
|
|
|
|
char *queryString;
|
|
|
|
void *body;
|
|
|
|
} Request;
|
|
|
|
|
|
|
|
Request* newRequest();
|
|
|
|
void requestFirstLine( Request *req, char line[] );
|
|
|
|
Request* newRequestFromSocket(int socket);
|
|
|
|
Request* newRequestFromString(char *string);
|
|
|
|
/*
|
|
|
|
* requestToString
|
|
|
|
* @prarm req the request to convert
|
|
|
|
*/
|
|
|
|
char* requestToString( Request *req );
|
|
|
|
void requestAddHeader( Request *req, char header[] );
|
|
|
|
|
|
|
|
void freeRequest( Request *req );
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* ifndef REQUEST_H */
|