some stuff
parent
abe5205aa0
commit
3c7740330a
Binary file not shown.
@ -1,22 +1,32 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef NO_GC
|
||||||
|
#include <gc.h>
|
||||||
|
#define malloc(n) GC_malloc(n)
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char method[16];
|
char *method;
|
||||||
char path[256];
|
char *path;
|
||||||
char protocol[16];
|
char protocol[16];
|
||||||
} ReqHeader;
|
} ReqHeader;
|
||||||
|
|
||||||
ReqHeader readReqHeader(int client) {
|
ReqHeader readReqHeader(int client) {
|
||||||
char buf[1024];
|
char* buf = malloc(1024);
|
||||||
read(client, buf, 1024);
|
read(client, buf, 1024);
|
||||||
ReqHeader header;
|
ReqHeader header;
|
||||||
strcpy(header.method, strtok(buf, " "));
|
header.method = malloc(1024);
|
||||||
strcpy(header.path, strtok(NULL, " "));
|
header.path = malloc(1024);
|
||||||
strcpy(header.protocol, strtok(NULL, " "));
|
/*strcpy(header.method, strtok(buf, " "));
|
||||||
|
strcpy(header.path, strtok(NULL, " "));*/
|
||||||
|
sprintf(header.method, "%s", strtok(buf, " "));
|
||||||
|
sprintf(header.path, "%s", strtok(NULL, " "));
|
||||||
if (header.path[1] == '\0') {
|
if (header.path[1] == '\0') {
|
||||||
strcpy(header.path, "/index.html");
|
//strcpy(header.path, "/index.html");
|
||||||
|
sprintf(header.path, "/index.html");
|
||||||
}
|
}
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue