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
34
src/response.h
Normal file
34
src/response.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef RESPONSE_H
|
||||
#define RESPONSE_H
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "readline.h"
|
||||
#include "requestresponse.h"
|
||||
|
||||
|
||||
/*
|
||||
* A struct reperesenting an http request
|
||||
*/
|
||||
typedef struct {
|
||||
// Common versions are: 0.9, 1.0, 1.1, 2.0
|
||||
float version;
|
||||
int statusCode;
|
||||
char *statusMessage;
|
||||
HeaderList *headers;
|
||||
char *body;
|
||||
unsigned int headerLength;
|
||||
} Response;
|
||||
|
||||
Response* newResponse();
|
||||
char *responseToString(Response *rsp);
|
||||
void responseSetBody(Response *rsp, char *string, bool updateContentLength);
|
||||
//void* responseAddHeader(Response *req, char line[]);
|
||||
|
||||
|
||||
|
||||
#endif /* ifndef REQUEST_H */
|
Loading…
Add table
Add a link
Reference in a new issue