-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
32 lines (27 loc) · 827 Bytes
/
main.cpp
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
#include <iostream>
#include <stdlib.h>
#include "Parser.hpp"
using namespace std;
int main()
{
char *http_header = "GET /index.html HTTP/1.0\r\n"
"Host: www.baidu.com\r\n"
"Connection: keep-alive\r\n"
"Accept: text/html,application/xml\r\n"
"User-Agent: Mozilla/5.0 (Macintosh) \r\n"
"Accept-Encoding: gzip, deflate, sdch\r\n"
"Accept-Language: zh-CN,zh;q=0.8\r\n"
"\r\n";
cout<<strlen(http_header)<<endl;
Parser parser(http_header,strlen(http_header));
vector<string> allParamters= parser.getParameters();
for(int i=0;i<allParamters.size();i++)
{
cout<<"Key: "<<allParamters[i]<<endl;
cout<<"Value: " << parser.getValueByParameter(allParamters[i])<<endl;
}
cout<<parser.getMethod()<<endl;
cout<<parser.getUri()<<endl;
cout<<parser.getVersion()<<endl;
return 0;
}