Work on requests

This commit adds tests for a request and the implementation.

The first line of a request should now be decoded correctly
This commit is contained in:
Jonathan Hodgson 2022-01-05 21:12:11 +00:00
parent 66d4702297
commit 0e2b9dae2b
4 changed files with 224 additions and 11 deletions

View file

@ -7,8 +7,6 @@
#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
@ -33,9 +31,9 @@ struct HeaderList {
*/
typedef struct {
// Common versions are: 0.9, 1.0, 1.1, 2.0
double version;
HTTPMethod method;
HTTPProtocol protocol;
float version;
char *method;
char *protocol;
char *host;
char *path;
HeaderList *headers;
@ -45,8 +43,10 @@ typedef struct {
Header* newHeader();
Request* newRequest();
void requestFirstLine( Request *req, char line[] );
Request* newRequestFromSocket(int socket);
void* addHeader(Request *req);
void* addHeader(Request *req, char line[]);
void* interpretLine1(Request *req, char line[]);