integrated changes from main repository

This commit is contained in:
Guenter Obiltschnig
2006-12-28 12:51:57 +00:00
parent fa8fde4880
commit 431807f25e
4 changed files with 17 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
// //
// HTTPChunkedStream.cpp // HTTPChunkedStream.cpp
// //
// $Id: //poco/1.3/Net/src/HTTPChunkedStream.cpp#2 $ // $Id: //poco/1.3/Net/src/HTTPChunkedStream.cpp#3 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP
@@ -102,7 +102,12 @@ int HTTPChunkedStreamBuf::readFromDevice(char* buffer, std::streamsize length)
if (n > 0) _chunk -= n; if (n > 0) _chunk -= n;
return n; return n;
} }
else return 0; else
{
int ch = _session.get();
while (ch != eof && ch != '\n') ch = _session.get();
return 0;
}
} }

View File

@@ -1,7 +1,7 @@
// //
// HTTPClientSession.cpp // HTTPClientSession.cpp
// //
// $Id: //poco/1.3/Net/src/HTTPClientSession.cpp#1 $ // $Id: //poco/1.3/Net/src/HTTPClientSession.cpp#2 $
// //
// Library: Net // Library: Net
// Package: HTTPClient // Package: HTTPClient
@@ -164,7 +164,8 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
close(); close();
if (!connected()) if (!connected())
reconnect(); reconnect();
request.setKeepAlive(keepAlive); if (!keepAlive)
request.setKeepAlive(false);
request.setHost(_host, _port); request.setHost(_host, _port);
if (!_proxyHost.empty()) if (!_proxyHost.empty())
request.setURI(getHostInfo() + request.getURI()); request.setURI(getHostInfo() + request.getURI());

View File

@@ -1,7 +1,7 @@
// //
// HTTPServerTest.cpp // HTTPServerTest.cpp
// //
// $Id: //poco/1.3/Net/testsuite/src/HTTPServerTest.cpp#1 $ // $Id: //poco/1.3/Net/testsuite/src/HTTPServerTest.cpp#2 $
// //
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -249,7 +249,7 @@ void HTTPServerTest::testIdentityRequestKeepAlive()
HTTPClientSession cs("localhost", svs.address().port()); HTTPClientSession cs("localhost", svs.address().port());
cs.setKeepAlive(true); cs.setKeepAlive(true);
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody"); HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
request.setContentType("text/plain"); request.setContentType("text/plain");
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
@@ -263,7 +263,7 @@ void HTTPServerTest::testIdentityRequestKeepAlive()
body.assign(1000, 'y'); body.assign(1000, 'y');
request.setContentLength((int) body.length()); request.setContentLength((int) body.length());
cs.setKeepAlive(false); request.setKeepAlive(false);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == body.size()); assert (response.getContentLength() == body.size());
@@ -283,7 +283,7 @@ void HTTPServerTest::testChunkedRequestKeepAlive()
HTTPClientSession cs("localhost", svs.address().port()); HTTPClientSession cs("localhost", svs.address().port());
cs.setKeepAlive(true); cs.setKeepAlive(true);
std::string body(5000, 'x'); std::string body(5000, 'x');
HTTPRequest request("POST", "/echoBody"); HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
request.setContentType("text/plain"); request.setContentType("text/plain");
request.setChunkedTransferEncoding(true); request.setChunkedTransferEncoding(true);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
@@ -296,7 +296,7 @@ void HTTPServerTest::testChunkedRequestKeepAlive()
assert (rbody == body); assert (rbody == body);
body.assign(1000, 'y'); body.assign(1000, 'y');
cs.setKeepAlive(false); request.setKeepAlive(false);
cs.sendRequest(request) << body; cs.sendRequest(request) << body;
cs.receiveResponse(response) >> rbody; cs.receiveResponse(response) >> rbody;
assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH); assert (response.getContentLength() == HTTPMessage::UNKNOWN_CONTENT_LENGTH);

View File

@@ -1,7 +1,7 @@
// //
// HTTPTestServer.cpp // HTTPTestServer.cpp
// //
// $Id: //poco/1.3/Net/testsuite/src/HTTPTestServer.cpp#1 $ // $Id: //poco/1.3/Net/testsuite/src/HTTPTestServer.cpp#2 $
// //
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@@ -199,7 +199,7 @@ std::string HTTPTestServer::handleRequest() const
response.append(NumberFormatter::formatHex((unsigned) body.length())); response.append(NumberFormatter::formatHex((unsigned) body.length()));
response.append("\r\n"); response.append("\r\n");
response.append(body); response.append(body);
response.append("\r\n0\r\n"); response.append("\r\n0\r\n\r\n");
response.append("HTTP/1.1 200 OK\r\n"); response.append("HTTP/1.1 200 OK\r\n");
response.append("Connection: close\r\n"); response.append("Connection: close\r\n");
response.append("Content-Type: text/plain\r\n"); response.append("Content-Type: text/plain\r\n");