Added more information to dynamic pages
This commit is contained in:
@@ -23,9 +23,26 @@ typedef struct {
|
|||||||
} Field;
|
} Field;
|
||||||
/*HTTP 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 {
|
typedef struct {
|
||||||
long fieldCount;
|
long fieldCount;
|
||||||
Field *fields;
|
Field *fields;
|
||||||
|
char *path;
|
||||||
|
RequestType type;
|
||||||
} Request;
|
} Request;
|
||||||
/*HTTP request, pretty self explanatory*/
|
/*HTTP request, pretty self explanatory*/
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
#include <swebs/swebs.h>
|
#include <swebs/swebs.h>
|
||||||
|
|
||||||
int getResponse(Request *request, Response *response) {
|
int getResponse(Request *request, Response *response) {
|
||||||
char *str = "<h1>Hello world!</h1>";
|
char *str = request->path;
|
||||||
response->type = BUFFER;
|
response->type = BUFFER;
|
||||||
response->response.buffer.data = malloc(30);
|
response->response.buffer.data = malloc(100);
|
||||||
strcpy(response->response.buffer.data, str);
|
strcpy(response->response.buffer.data, str);
|
||||||
response->response.buffer.len = strlen(str);
|
response->response.buffer.len = strlen(str);
|
||||||
return 200;
|
return 200;
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ static int linkedResponse(Connection *conn,
|
|||||||
|
|
||||||
request.fieldCount = conn->fieldCount;
|
request.fieldCount = conn->fieldCount;
|
||||||
request.fields = conn->fields;
|
request.fields = conn->fields;
|
||||||
|
request.path = conn->path;
|
||||||
|
request.type = conn->type;
|
||||||
|
|
||||||
code = getResponse(&request, &response);
|
code = getResponse(&request, &response);
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
long fieldCount;
|
long fieldCount;
|
||||||
Field *fields;
|
Field *fields;
|
||||||
|
char *path;
|
||||||
|
RequestType type;
|
||||||
} Request;
|
} Request;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user