making requests to something like example.com over a non-encrypted connection now works. Binary files are unlikely to work at the moment although I haven't tried. Also, non-encrypted doesn't work. I have also changed a little about how tests work. Requests tests now display much better.
50 lines
1.2 KiB
C
50 lines
1.2 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);
|
|
|
|
void freeHeader(Header *header);
|
|
|
|
//Adds a header to the end of a header list
|
|
void addHeader(HeaderList *headers, char *str);
|
|
|
|
void freeHeaderList(HeaderList *headers);
|
|
|
|
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
|
|
*/
|