fixed GH# 172: IPv6 Host field is stripped of Brackets in HTTPClientSession

This commit is contained in:
Guenter Obiltschnig
2013-05-24 21:08:10 +02:00
parent ab85e7077f
commit 94ee8fa76e
3 changed files with 32 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
//
// HTTPRequestTest.cpp
//
// $Id: //poco/1.4/Net/testsuite/src/HTTPRequestTest.cpp#3 $
// $Id: //poco/1.4/Net/testsuite/src/HTTPRequestTest.cpp#4 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -73,7 +73,7 @@ void HTTPRequestTest::testWrite2()
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "HEAD /index.html HTTP/1.1\r\nHost: localhost\r\nConnection: Keep-Alive\r\nUser-Agent: Poco\r\n\r\n");
assert (s == "HEAD /index.html HTTP/1.1\r\nConnection: Keep-Alive\r\nHost: localhost\r\nUser-Agent: Poco\r\n\r\n");
}
@@ -88,7 +88,20 @@ void HTTPRequestTest::testWrite3()
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "POST /test.cgi HTTP/1.1\r\nHost: localhost:8000\r\nConnection: Close\r\nUser-Agent: Poco\r\nContent-Length: 100\r\nContent-Type: text/plain\r\n\r\n");
assert (s == "POST /test.cgi HTTP/1.1\r\nConnection: Close\r\nContent-Length: 100\r\nContent-Type: text/plain\r\nHost: localhost:8000\r\nUser-Agent: Poco\r\n\r\n");
}
void HTTPRequestTest::testWrite4()
{
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/index.html", HTTPMessage::HTTP_1_1);
request.setHost("fe80::1", 88);
request.setKeepAlive(true);
request.set("User-Agent", "Poco");
std::ostringstream ostr;
request.write(ostr);
std::string s = ostr.str();
assert (s == "HEAD /index.html HTTP/1.1\r\nConnection: Keep-Alive\r\nHost: [fe80::1]:88\r\nUser-Agent: Poco\r\n\r\n");
}
@@ -262,6 +275,7 @@ CppUnit::Test* HTTPRequestTest::suite()
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite1);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite2);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite3);
CppUnit_addTest(pSuite, HTTPRequestTest, testWrite4);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead1);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead2);
CppUnit_addTest(pSuite, HTTPRequestTest, testRead3);