Added more information to dynamic pages
This commit is contained in:
@@ -23,9 +23,26 @@ typedef struct {
|
||||
} Field;
|
||||
/*HTTP field*/
|
||||
|
||||
typedef enum {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
HEAD,
|
||||
DELETE,
|
||||
PATCH,
|
||||
OPTIONS,
|
||||
INVALID
|
||||
/*
|
||||
* Indicates an invalid type of request, if you see this then
|
||||
* something's gone terribly wrong.
|
||||
* */
|
||||
} RequestType;
|
||||
|
||||
typedef struct {
|
||||
long fieldCount;
|
||||
Field *fields;
|
||||
char *path;
|
||||
RequestType type;
|
||||
} Request;
|
||||
/*HTTP request, pretty self explanatory*/
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <swebs/swebs.h>
|
||||
|
||||
int getResponse(Request *request, Response *response) {
|
||||
char *str = "<h1>Hello world!</h1>";
|
||||
char *str = request->path;
|
||||
response->type = BUFFER;
|
||||
response->response.buffer.data = malloc(30);
|
||||
response->response.buffer.data = malloc(100);
|
||||
strcpy(response->response.buffer.data, str);
|
||||
response->response.buffer.len = strlen(str);
|
||||
return 200;
|
||||
|
||||
@@ -160,6 +160,8 @@ static int linkedResponse(Connection *conn,
|
||||
|
||||
request.fieldCount = conn->fieldCount;
|
||||
request.fields = conn->fields;
|
||||
request.path = conn->path;
|
||||
request.type = conn->type;
|
||||
|
||||
code = getResponse(&request, &response);
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
long fieldCount;
|
||||
Field *fields;
|
||||
char *path;
|
||||
RequestType type;
|
||||
} Request;
|
||||
|
||||
typedef enum {
|
||||
|
||||
Reference in New Issue
Block a user