56 {
57 std::string raw = "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
58
59 std::string firefox = "GET / HTTP/1.1\r\nHost: localhost:5000\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0) Gecko/20100101 Firefox/10.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive, Upgrade\r\nSec-WebSocket-Version: 8\r\nSec-WebSocket-Origin: http://zaphoyd.com\r\nSec-WebSocket-Key: pFik//FxwFk0riN4ZiPFjQ==\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nUpgrade: websocket\r\n\r\n";
60
61 std::string firefox1 = "GET / HTTP/1.1\r\nHost: localhost:5000\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0) Gecko/20100101 Firefox/10.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\n";
62
63 std::string firefox2 = "Accept-Encoding: gzip, deflate\r\nConnection: keep-alive, Upgrade\r\nSec-WebSocket-Version: 8\r\nSec-WebSocket-Origin: http://zaphoyd.com\r\nSec-WebSocket-Key: pFik//FxwFk0riN4ZiPFjQ==\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nUpgrade: websocket\r\n\r\n";
64
65 {
67 for (int i = 0; i < 1000; i++) {
69
70 try {
71 r.consume(raw.c_str(),raw.size());
72 } catch (...) {
73 std::cout << "exception" << std::endl;
74 }
75
77 std::cout << "error" << std::endl;
78 break;
79 }
80 }
81 }
82
83 {
85 for (int i = 0; i < 1000; i++) {
87
88 try {
89 r.consume2(firefox.c_str(),firefox.size());
90 } catch (...) {
91 std::cout << "exception" << std::endl;
92 }
93
95 std::cout << "error" << std::endl;
96 break;
97 }
98 }
99 }
100
101 {
103 for (int i = 0; i < 1000; i++) {
105
106 try {
107 r.consume(firefox.c_str(),firefox.size());
108 } catch (...) {
109 std::cout << "exception" << std::endl;
110 }
111
113 std::cout << "error" << std::endl;
114 break;
115 }
116 }
117 }
118
119
120
121 {
123 for (int i = 0; i < 1000; i++) {
125
126 try {
127 r.consume(firefox1.c_str(),firefox1.size());
128 r.consume(firefox2.c_str(),firefox2.size());
129 } catch (...) {
130 std::cout << "exception" << std::endl;
131 }
132
134 std::cout << "error" << std::endl;
135 break;
136 }
137 }
138 }
139
140 return 0;
141}
Stores, parses, and manipulates HTTP requests.