|
|
@ -22,13 +22,13 @@ int main() { |
|
|
|
assert(req->version == "HTTP/1.0"); |
|
|
|
assert(req->version == "HTTP/1.0"); |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->uri == "/"); |
|
|
|
assert(req->uri == "/"); |
|
|
|
assert(req->headers.size() == 3); |
|
|
|
assert(req->GetNumHeaders () == 3); |
|
|
|
assert(req->headers.count("Host") == 1); |
|
|
|
assert(req->GetNumHeaders("Host") == 1); |
|
|
|
assert(req->headers.count("Accept") == 1); |
|
|
|
assert(req->GetNumHeaders("Accept") == 1); |
|
|
|
assert(req->headers.count("User-Agent") == 1); |
|
|
|
assert(req->GetNumHeaders("User-Agent") == 1); |
|
|
|
assert(req->headers.find("Host")->second == "inr.i2p"); |
|
|
|
assert(req->GetHeader("Host") == "inr.i2p"); |
|
|
|
assert(req->headers.find("Accept")->second == "*/*"); |
|
|
|
assert(req->GetHeader("Accept") == "*/*"); |
|
|
|
assert(req->headers.find("User-Agent")->second == "curl/7.26.0"); |
|
|
|
assert(req->GetHeader("User-Agent") == "curl/7.26.0"); |
|
|
|
delete req; |
|
|
|
delete req; |
|
|
|
|
|
|
|
|
|
|
|
/* test: parsing request without body */ |
|
|
|
/* test: parsing request without body */ |
|
|
@ -41,7 +41,7 @@ int main() { |
|
|
|
assert(req->version == "HTTP/1.0"); |
|
|
|
assert(req->version == "HTTP/1.0"); |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->uri == "/"); |
|
|
|
assert(req->uri == "/"); |
|
|
|
assert(req->headers.size() == 0); |
|
|
|
assert(req->GetNumHeaders () == 0); |
|
|
|
delete req; |
|
|
|
delete req; |
|
|
|
|
|
|
|
|
|
|
|
/* test: parsing request without body */ |
|
|
|
/* test: parsing request without body */ |
|
|
@ -74,13 +74,13 @@ int main() { |
|
|
|
assert((ret = req->parse(buf, len)) == len); /* no host header */ |
|
|
|
assert((ret = req->parse(buf, len)) == len); /* no host header */ |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->method == "GET"); |
|
|
|
assert(req->uri == "http://inr.i2p"); |
|
|
|
assert(req->uri == "http://inr.i2p"); |
|
|
|
assert(req->headers.size() == 3); |
|
|
|
assert(req->GetNumHeaders () == 3); |
|
|
|
assert(req->headers.count("Host") == 1); |
|
|
|
assert(req->GetNumHeaders("Host") == 1); |
|
|
|
assert(req->headers.count("Accept") == 1); |
|
|
|
assert(req->GetNumHeaders("Accept") == 1); |
|
|
|
assert(req->headers.count("Accept-Encoding") == 1); |
|
|
|
assert(req->GetNumHeaders("Accept-Encoding") == 1); |
|
|
|
assert(req->headers["Host"] == "stats.i2p"); |
|
|
|
assert(req->GetHeader("Host") == "stats.i2p"); |
|
|
|
assert(req->headers["Accept"] == "*/*"); |
|
|
|
assert(req->GetHeader("Accept") == "*/*"); |
|
|
|
assert(req->headers["Accept-Encoding"] == ""); |
|
|
|
assert(req->GetHeader("Accept-Encoding") == ""); |
|
|
|
delete req; |
|
|
|
delete req; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|