Yet Another Intercepting Proxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.0 KiB

#ifndef REQUEST_H
#define REQUEST_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "readline.h"
#include <netinet/in.h>
typedef enum {HTTP,HTTPS} HTTPProtocol;
typedef enum {GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, PATCH} HTTPMethod;
/*
* A struct reperesenting an http header
*/
typedef struct {
char *name;
// The spec doesn't specify a max size for headers, but nginx doesn't accept headers bigger than 4096 so that's probably ok for us
char *value;
} Header;
/*
* A linked list wrapper around the headers
*/
typedef struct HeaderList HeaderList;
struct HeaderList {
Header header;
HeaderList *next;
};
/*
* A struct reperesenting an http request
*/
typedef struct {
// Common versions are: 0.9, 1.0, 1.1, 2.0
double version;
HTTPMethod method;
HTTPProtocol protocol;
char *host;
char *path;
HeaderList *headers;
char *queryString;
char *body;
} Request;
Header* newHeader();
Request* newRequest();
Request* newRequestFromSocket(int socket);
void* addHeader(Request *req);
#endif /* ifndef REQUEST_H */