performance improvements from 1.3.4

This commit is contained in:
Guenter Obiltschnig 2009-02-18 13:25:01 +00:00
parent 64a7203a0d
commit 717dd9cf45
10 changed files with 423 additions and 426 deletions

View File

@ -1,7 +1,7 @@
// //
// HTTPMessage.h // HTTPMessage.h
// //
// $Id: //poco/svn/Net/include/Poco/Net/HTTPMessage.h#2 $ // $Id: //poco/Main/Net/include/Poco/Net/HTTPMessage.h#3 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP

View File

@ -1,7 +1,7 @@
// //
// HTTPServerRequestImpl.h // HTTPServerRequestImpl.h
// //
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerRequestImpl.h#2 $ // $Id: //poco/Main/Net/include/Poco/Net/HTTPServerRequestImpl.h#4 $
// //
// Library: Net // Library: Net
// Package: HTTPServer // Package: HTTPServer
@ -43,6 +43,7 @@
#include "Poco/Net/Net.h" #include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/SocketAddress.h" #include "Poco/Net/SocketAddress.h"
#include "Poco/AutoPtr.h"
#include <istream> #include <istream>
@ -96,11 +97,11 @@ protected:
static const std::string EXPECT; static const std::string EXPECT;
private: private:
HTTPServerResponse& _response; HTTPServerResponse& _response;
std::istream* _pStream; std::istream* _pStream;
HTTPServerParams* _pParams; Poco::AutoPtr<HTTPServerParams> _pParams;
SocketAddress _clientAddress; SocketAddress _clientAddress;
SocketAddress _serverAddress; SocketAddress _serverAddress;
}; };

View File

@ -1,7 +1,7 @@
// //
// HTTPCookie.cpp // HTTPCookie.cpp
// //
// $Id: //poco/1.3/Net/src/HTTPCookie.cpp#2 $ // $Id: //poco/Main/Net/src/HTTPCookie.cpp#8 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP

View File

@ -1,7 +1,7 @@
// //
// HTTPMessage.cpp // HTTPMessage.cpp
// //
// $Id: //poco/svn/Net/src/HTTPMessage.cpp#2 $ // $Id: //poco/Main/Net/src/HTTPMessage.cpp#8 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP

View File

@ -1,7 +1,7 @@
// //
// HTTPRequest.cpp // HTTPRequest.cpp
// //
// $Id: //poco/svn/Net/src/HTTPRequest.cpp#2 $ // $Id: //poco/Main/Net/src/HTTPRequest.cpp#13 $
// //
// Library: Net // Library: Net
// Package: HTTP // Package: HTTP

View File

@ -1,7 +1,7 @@
// //
// HTTPServerConnection.cpp // HTTPServerConnection.cpp
// //
// $Id: //poco/svn/Net/src/HTTPServerConnection.cpp#2 $ // $Id: //poco/Main/Net/src/HTTPServerConnection.cpp#11 $
// //
// Library: Net // Library: Net
// Package: HTTPServer // Package: HTTPServer
@ -43,6 +43,7 @@
#include "Poco/Net/HTTPServerParams.h" #include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/NetException.h" #include "Poco/Net/NetException.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/Timestamp.h"
#include <memory> #include <memory>
@ -79,6 +80,8 @@ void HTTPServerConnection::run()
HTTPServerResponseImpl response(session); HTTPServerResponseImpl response(session);
HTTPServerRequestImpl request(response, session, _pParams); HTTPServerRequestImpl request(response, session, _pParams);
Poco::Timestamp now;
response.setDate(now);
response.setVersion(request.getVersion()); response.setVersion(request.getVersion());
response.setKeepAlive(_pParams->getKeepAlive() && request.getKeepAlive() && session.canKeepAlive()); response.setKeepAlive(_pParams->getKeepAlive() && request.getKeepAlive() && session.canKeepAlive());
if (!server.empty()) if (!server.empty())

View File

@ -1,7 +1,7 @@
// //
// HTTPServerRequestImpl.cpp // HTTPServerRequestImpl.cpp
// //
// $Id: //poco/svn/Net/src/HTTPServerRequestImpl.cpp#2 $ // $Id: //poco/Main/Net/src/HTTPServerRequestImpl.cpp#4 $
// //
// Library: Net // Library: Net
// Package: HTTPServer // Package: HTTPServer
@ -57,12 +57,8 @@ const std::string HTTPServerRequestImpl::EXPECT("Expect");
HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams): HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams):
_response(response), _response(response),
_pStream(0), _pStream(0),
_pParams(pParams) _pParams(pParams, true)
{ {
poco_check_ptr (_pParams);
_pParams->duplicate();
HTTPHeaderInputStream hs(session); HTTPHeaderInputStream hs(session);
read(hs); read(hs);
@ -83,7 +79,6 @@ HTTPServerRequestImpl::HTTPServerRequestImpl(HTTPServerResponse& response, HTTPS
HTTPServerRequestImpl::~HTTPServerRequestImpl() HTTPServerRequestImpl::~HTTPServerRequestImpl()
{ {
_pParams->release();
delete _pStream; delete _pStream;
} }

View File

@ -1,7 +1,7 @@
// //
// HTTPServerResponseImpl.cpp // HTTPServerResponseImpl.cpp
// //
// $Id: //poco/svn/Net/src/HTTPServerResponseImpl.cpp#3 $ // $Id: //poco/Main/Net/src/HTTPServerResponseImpl.cpp#6 $
// //
// Library: Net // Library: Net
// Package: HTTPServer // Package: HTTPServer
@ -68,8 +68,6 @@ HTTPServerResponseImpl::HTTPServerResponseImpl(HTTPServerSession& session):
_session(session), _session(session),
_pStream(0) _pStream(0)
{ {
Timestamp now;
setDate(now);
} }
@ -128,7 +126,7 @@ void HTTPServerResponseImpl::sendFile(const std::string& path, const std::string
Poco::FileInputStream istr(path); Poco::FileInputStream istr(path);
if (istr.good()) if (istr.good())
{ {
_pStream = new HTTPOutputStream(_session); _pStream = new HTTPHeaderOutputStream(_session);
write(*_pStream); write(*_pStream);
StreamCopier::copyStream(istr, *_pStream); StreamCopier::copyStream(istr, *_pStream);
} }
@ -143,7 +141,7 @@ void HTTPServerResponseImpl::sendBuffer(const void* pBuffer, std::size_t length)
setContentLength(static_cast<int>(length)); setContentLength(static_cast<int>(length));
setChunkedTransferEncoding(false); setChunkedTransferEncoding(false);
_pStream = new HTTPOutputStream(_session); _pStream = new HTTPHeaderOutputStream(_session);
write(*_pStream); write(*_pStream);
_pStream->write(static_cast<const char*>(pBuffer), static_cast<std::streamsize>(length)); _pStream->write(static_cast<const char*>(pBuffer), static_cast<std::streamsize>(length));
} }

View File

@ -1,7 +1,7 @@
// //
// MessageHeader.cpp // MessageHeader.cpp
// //
// $Id: //poco/svn/Net/src/MessageHeader.cpp#2 $ // $Id: //poco/Main/Net/src/MessageHeader.cpp#13 $
// //
// Library: Net // Library: Net
// Package: Messages // Package: Messages

View File

@ -1,7 +1,7 @@
// //
// NameValueCollection.cpp // NameValueCollection.cpp
// //
// $Id: //poco/svn/Net/src/NameValueCollection.cpp#2 $ // $Id: //poco/Main/Net/src/NameValueCollection.cpp#8 $
// //
// Library: Net // Library: Net
// Package: Messages // Package: Messages