mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 14:39:53 +01:00
SF#3500438: HTTPResponse failure when reason is empty
This commit is contained in:
parent
3d142783c7
commit
0dc113b2f3
@ -236,7 +236,7 @@ void HTTPResponse::read(std::istream& istr)
|
|||||||
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
|
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
|
||||||
while (!Poco::Ascii::isSpace(ch) && ch != eof && status.length() < MAX_STATUS_LENGTH) { status += (char) ch; ch = istr.get(); }
|
while (!Poco::Ascii::isSpace(ch) && ch != eof && status.length() < MAX_STATUS_LENGTH) { status += (char) ch; ch = istr.get(); }
|
||||||
if (!Poco::Ascii::isSpace(ch)) throw MessageException("Invalid HTTP status code");
|
if (!Poco::Ascii::isSpace(ch)) throw MessageException("Invalid HTTP status code");
|
||||||
while (Poco::Ascii::isSpace(ch)) ch = istr.get();
|
while (Poco::Ascii::isSpace(ch) && ch != '\r' && ch != '\n' && ch != eof) ch = istr.get();
|
||||||
while (ch != '\r' && ch != '\n' && ch != eof && reason.length() < MAX_REASON_LENGTH) { reason += (char) ch; ch = istr.get(); }
|
while (ch != '\r' && ch != '\n' && ch != eof && reason.length() < MAX_REASON_LENGTH) { reason += (char) ch; ch = istr.get(); }
|
||||||
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP reason string too long");
|
if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP reason string too long");
|
||||||
if (ch == '\r') ch = istr.get();
|
if (ch == '\r') ch = istr.get();
|
||||||
|
@ -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()
|
void HTTPResponseTest::testInvalid1()
|
||||||
{
|
{
|
||||||
std::string s(256, 'x');
|
std::string s(256, 'x');
|
||||||
@ -226,6 +241,7 @@ CppUnit::Test* HTTPResponseTest::suite()
|
|||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testWrite2);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testWrite2);
|
||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testRead1);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testRead1);
|
||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testRead2);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testRead2);
|
||||||
|
CppUnit_addTest(pSuite, HTTPResponseTest, testRead3);
|
||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid1);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid1);
|
||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid2);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid2);
|
||||||
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid3);
|
CppUnit_addTest(pSuite, HTTPResponseTest, testInvalid3);
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
void testWrite2();
|
void testWrite2();
|
||||||
void testRead1();
|
void testRead1();
|
||||||
void testRead2();
|
void testRead2();
|
||||||
|
void testRead3();
|
||||||
void testInvalid1();
|
void testInvalid1();
|
||||||
void testInvalid2();
|
void testInvalid2();
|
||||||
void testInvalid3();
|
void testInvalid3();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user