SF#3500438: HTTPResponse failure when reason is empty

This commit is contained in:
Aleksandar Fabijanic
2012-08-22 02:28:00 +00:00
parent 3d142783c7
commit 0dc113b2f3
3 changed files with 18 additions and 1 deletions

View File

@@ -107,6 +107,21 @@ void HTTPResponseTest::testRead2()
}
void HTTPResponseTest::testRead3()
{
std::string s("HTTP/1.1 200 \r\nContent-Length: 0\r\n\r\n");
std::istringstream istr(s);
HTTPResponse response;
response.read(istr);
assert (response.getVersion() == HTTPMessage::HTTP_1_1);
assert (response.getStatus() == HTTPResponse::HTTP_OK);
assert (response.getReason() == "");
assert (response.size() == 1);
assert (response.getContentLength() == 0);
assert (istr.get() == -1);
}
void HTTPResponseTest::testInvalid1()
{
std::string s(256, 'x');
@@ -226,6 +241,7 @@ CppUnit::Test* HTTPResponseTest::suite()
CppUnit_addTest(pSuite, HTTPResponseTest, testWrite2);
CppUnit_addTest(pSuite, HTTPResponseTest, testRead1);
CppUnit_addTest(pSuite, HTTPResponseTest, testRead2);
CppUnit_addTest(pSuite, HTTPResponseTest, testRead3);
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid1);
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid2);
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid3);