-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_parser.c
48 lines (40 loc) · 888 Bytes
/
http_parser.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
#include "util.h"
char* get_url_path(char* str, char *url_path){
str += strlen("GET ");
int url_length = 0;
while (strncmp(" ", str+url_length, 1)){
url_length += 1;
}
strncpy(url_path, str, url_length);
str += url_length;
while (strncmp("\n", str, 1))
{
str += 1;
}
return str;
}
void http_parse(char* str, Request* request){
if(!strncmp("GET", str, 3)){
str = get_url_path(str, request->url_path);
}
while (*str)
{
if(strncmp("\r\n\r\n", str, 4)){
str += 1;
}
else
{
printf("read all header\n");
break;
}
}
//printf("url_path = %s\n", request->url_path);
return;
}
// HTTP versionを確認
ptr = buf + 5;
if (strncmp("1.0 ", ptr, 4) == 0) {
printf("is HTTP/1.0\n");
ptr += 4;
*/