Split out some stuff that is shared between request and response
I now have files with the infinitely imaginative names requestrespons.{c,h,test.c}.
This commit is contained in:
parent
0e2b9dae2b
commit
48e3092317
9 changed files with 533 additions and 70 deletions
46
src/requestresponse.h
Normal file
46
src/requestresponse.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
#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
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue