46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#ifndef REQUESTRESPONSE
|
|
#define REQUESTRESPONSE
|
|
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
//This file contains definitions that are shared between requests and responses such as header
|
|
/*
|
|
* 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;
|
|
};
|
|
|
|
//Creates a new header struct from a string like "Content-Length: 123"
|
|
Header* newHeader(char *str);
|
|
|
|
//Adds a header to the end of a header list
|
|
void addHeader(HeaderList *headers, char *str);
|
|
|
|
Header* getHeader(HeaderList *headers, char *name);
|
|
|
|
unsigned int countHeaders(HeaderList *headers);
|
|
|
|
|
|
unsigned int headerListCharLength(HeaderList *headers);
|
|
|
|
char* headersToString(HeaderList *headers);
|
|
|
|
#endif /* ifndef REQUESTRESPONSE
|
|
|
|
//THis file contains definitions that are shared between requests and responses such as header
|
|
*/
|