* update tests

pull/503/head
hagen 8 years ago
parent 2ce61402bb
commit b68f06ca83

@ -3,11 +3,12 @@
using namespace i2p::http;
int main(int argc, char *argv[]) {
int main() {
HTTPReq *req;
int ret = 0, len = 0;
const char *buf;
/* test: parsing request with body */
buf =
"GET / HTTP/1.0\r\n"
"User-Agent: curl/7.26.0\r\n"
@ -31,6 +32,7 @@ int main(int argc, char *argv[]) {
assert(req->headers.find("User-Agent")->second == "curl/7.26.0");
delete req;
/* test: parsing request without body */
buf =
"GET / HTTP/1.0\r\n"
"\r\n";
@ -44,6 +46,7 @@ int main(int argc, char *argv[]) {
assert(req->headers.size() == 0);
delete req;
/* test: parsing request without body */
buf =
"GET / HTTP/1.1\r\n"
"\r\n";
@ -52,6 +55,7 @@ int main(int argc, char *argv[]) {
assert((ret = req->parse(buf, len)) == -1); /* no host header */
delete req;
/* test: parsing incomplete request */
buf =
"GET / HTTP/1.0\r\n"
"";
@ -60,6 +64,7 @@ int main(int argc, char *argv[]) {
assert((ret = req->parse(buf, len)) == 0); /* request not completed */
delete req;
/* test: parsing slightly malformed request */
buf =
"GET http://inr.i2p HTTP/1.1\r\n"
"Host: stats.i2p\r\n"

@ -3,11 +3,12 @@
using namespace i2p::http;
int main(int argc, char *argv[]) {
int main() {
HTTPRes *res;
int ret = 0, len = 0;
const char *buf;
/* test: parsing valid response without body */
buf =
"HTTP/1.1 304 Not Modified\r\n"
"Date: Thu, 14 Apr 2016 00:00:00 GMT\r\n"
@ -31,6 +32,18 @@ int main(int argc, char *argv[]) {
assert(res->length() == 536);
delete res;
/* test: building request */
buf =
"HTTP/1.0 304 Not Modified\r\n"
"Content-Length: 0\r\n"
"\r\n";
res = new HTTPRes;
res->version = "HTTP/1.0";
res->code = 304;
res->status = "Not Modified";
res->add_header("Content-Length", "0");
assert(res->to_string() == buf);
return 0;
}

@ -3,7 +3,7 @@
using namespace i2p::http;
int main(int argc, char *argv[]) {
int main() {
std::map<std::string, std::string> params;
URL *url;

@ -3,7 +3,7 @@
using namespace i2p::http;
int main(int argc, char *argv[]) {
int main() {
std::string in("/%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0/");
std::string out = UrlDecode(in);

Loading…
Cancel
Save