You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
464 B

#include <stdio.h>
#include <unistd.h>
#include <string.h>
typedef struct {
char method[16];
char path[256];
char protocol[10];
} ReqHeader;
ReqHeader readReqHeader(int client) {
char buf[1024];
read(client, buf, 1024);
ReqHeader header;
strcpy(header.method, strtok(buf, " "));
strcpy(header.path, strtok(NULL, " "));
strcpy(header.protocol, strtok(NULL, " "));
if (header.path[1] == '\0') {
strcpy(header.path, "/index.html");
}
return header;
}