moved content-range parsing into http_parser and added unittest

This commit is contained in:
Arvid Norberg
2009-04-12 17:52:25 +00:00
parent a79932c9fd
commit 066d6ce799
4 changed files with 48 additions and 35 deletions

View File

@@ -546,6 +546,22 @@ int test_main()
TEST_CHECK(received == make_tuple(5, int(strlen(tracker_response) - 5), false));
TEST_CHECK(parser.get_body().left() == 5);
parser.reset();
// make sure we support content-range responses
// and that we're case insensitive
char const* web_seed_response =
"HTTP/1.1 206 OK\n"
"contEnt-rAngE: bYTes 0-4\n"
"conTent-TyPe: test/plain\n"
"\n"
"\ntest";
received = feed_bytes(parser, web_seed_response);
TEST_CHECK(received == make_tuple(5, int(strlen(web_seed_response) - 5), false));
TEST_CHECK(parser.content_range() == (std::pair<size_type, size_type>(0, 4)));
TEST_CHECK(parser.content_length() == 5);
// test xml parser
char xml1[] = "<a>foo<b/>bar</a>";