MCPcopy Create free account
hub / github.com/aria2/aria2 / testGetHttpResponseHeader

Method testGetHttpResponseHeader

test/HttpHeaderProcessorTest.cc:118–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void HttpHeaderProcessorTest::testGetHttpResponseHeader()
119{
120 HttpHeaderProcessor proc(HttpHeaderProcessor::CLIENT_PARSER);
121 std::string hd = "HTTP/1.1 404 Not Found\r\n"
122 "Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n"
123 "Server: Apache/2.2.3 (Debian)\r\n"
124 "Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n"
125 "ETag: \"594065-23e3-50825cc0\"\r\n"
126 "Accept-Ranges: bytes\r\n"
127 "Content-Length: 9187\r\n"
128 "Connection: close\r\n"
129 "Content-Type: text/html; charset=UTF-8\r\n"
130 "\r\n"
131 "Content-Encoding: body";
132
133 CPPUNIT_ASSERT(proc.parse(hd));
134
135 auto header = proc.getResult();
136 CPPUNIT_ASSERT_EQUAL(404, header->getStatusCode());
137 CPPUNIT_ASSERT_EQUAL(std::string("Not Found"), header->getReasonPhrase());
138 CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1"), header->getVersion());
139 CPPUNIT_ASSERT_EQUAL(std::string("9187"),
140 header->find(HttpHeader::CONTENT_LENGTH));
141 CPPUNIT_ASSERT_EQUAL(std::string("text/html; charset=UTF-8"),
142 header->find(HttpHeader::CONTENT_TYPE));
143 CPPUNIT_ASSERT(!header->defined(HttpHeader::CONTENT_ENCODING));
144}
145
146void HttpHeaderProcessorTest::testGetHttpResponseHeader_statusOnly()
147{

Callers

nothing calls this directly

Calls 5

parseMethod · 0.45
getResultMethod · 0.45
getStatusCodeMethod · 0.45
findMethod · 0.45
definedMethod · 0.45

Tested by

no test coverage detected