Merge branch 'poco-1.10.0' of https://github.com/pocoproject/poco into poco-1.10.0

This commit is contained in:
Francis ANDRE 2019-12-17 10:10:01 +01:00
commit 4e87b69de4
19 changed files with 85 additions and 229 deletions

View File

@ -175,19 +175,19 @@ extern "C" int ApacheConnector_handler(request_rec *r)
{
ApacheRequestRec rec(r);
ApacheApplication& app(ApacheApplication::instance());
try
{
// ensure application is ready
app.setup();
// if the ApacheRequestHandler declines handling - we stop
// request handling here and let other modules do their job!
if (!app.factory().mustHandle(r->uri))
return DECLINED;
apr_status_t rv;
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
return rv;
// The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4.
@ -199,16 +199,6 @@ extern "C" int ApacheConnector_handler(request_rec *r)
const char* clientIp = r->connection->client_ip;
apr_port_t clientPort = r->connection->client_addr->port;
#endif
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
&rec,
r->connection->local_ip,
r->connection->local_addr->port,
clientIp,
clientPort));
std::auto_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
#else
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
&rec,
r->connection->local_ip,
@ -217,22 +207,17 @@ extern "C" int ApacheConnector_handler(request_rec *r)
clientPort));
std::unique_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
#endif // POCO_ENABLE_CPP11
// add header information to request
rec.copyHeaders(*pRequest);
try
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<HTTPRequestHandler> pHandler(app.factory().createRequestHandler(*pRequest));
#else
std::unique_ptr<HTTPRequestHandler> pHandler(app.factory().createRequestHandler(*pRequest));
#endif // POCO_ENABLE_CPP11
if (pHandler.get())
{
{
pHandler->handleRequest(*pRequest, *pResponse);
}
else
@ -300,25 +285,25 @@ extern "C" const char* ApacheConnector_config(cmd_parms *cmd, void *in_dconf, co
}
extern "C" const command_rec ApacheConnector_cmds[] =
extern "C" const command_rec ApacheConnector_cmds[] =
{
AP_INIT_RAW_ARGS(
"AddPocoRequestHandler",
reinterpret_cast<cmd_func>(ApacheConnector_uris),
"AddPocoRequestHandler",
reinterpret_cast<cmd_func>(ApacheConnector_uris),
NULL,
RSRC_CONF,
RSRC_CONF,
"POCO RequestHandlerFactory class name followed by shared library path followed by a list of ' ' separated URIs that must be handled by this module."),
AP_INIT_RAW_ARGS(
"AddPocoConfig",
reinterpret_cast<cmd_func>(ApacheConnector_config),
"AddPocoConfig",
reinterpret_cast<cmd_func>(ApacheConnector_config),
NULL,
RSRC_CONF,
RSRC_CONF,
"Path of the POCO configuration file."),
{ NULL }
};
module AP_MODULE_DECLARE_DATA poco_module =
module AP_MODULE_DECLARE_DATA poco_module =
{
STANDARD20_MODULE_STUFF,
NULL,

View File

@ -54,8 +54,8 @@ class TestCaller: public TestCase
typedef void (Fixture::*TestMethod)();
public:
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
TestCase(name, testType),
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
TestCase(name, testType),
_test(test),
_fixture(new Fixture(name))
{
@ -81,11 +81,7 @@ protected:
private:
TestMethod _test;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<Fixture> _fixture;
#else
std::unique_ptr<Fixture> _fixture;
#endif // POCO_ENABLE_CPP11
};

View File

@ -90,11 +90,7 @@ private:
void load(PKCS12* pPKCS12, const std::string& password = "");
std::string extractFriendlyName(X509* pCert);
#ifdef POCO_ENABLE_CPP11
typedef std::unique_ptr<X509Certificate> CertPtr;
#else
typedef std::auto_ptr<X509Certificate> CertPtr;
#endif // #ifdef POCO_ENABLE_CPP11
OpenSSLInitializer _openSSLInitializer;
EVP_PKEY* _pKey;

View File

@ -42,7 +42,7 @@ public:
}
~DynamicFactory()
/// Destroys the DynamicFactory and deletes the instantiators for
/// Destroys the DynamicFactory and deletes the instantiators for
/// all registered classes.
{
for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
@ -50,7 +50,7 @@ public:
delete it->second;
}
}
Base* createInstance(const std::string& className) const
/// Creates a new instance of the class with the given name.
/// The class must have been registered with registerClass.
@ -64,8 +64,8 @@ public:
else
throw NotFoundException(className);
}
template <class C>
template <class C>
void registerClass(const std::string& className)
/// Registers the instantiator for the given class with the DynamicFactory.
/// The DynamicFactory takes ownership of the instantiator and deletes
@ -75,7 +75,7 @@ public:
{
registerClass(className, new Instantiator<C, Base>);
}
void registerClass(const std::string& className, AbstractFactory* pAbstractFactory)
/// Registers the instantiator for the given class with the DynamicFactory.
/// The DynamicFactory takes ownership of the instantiator and deletes
@ -87,11 +87,7 @@ public:
FastMutex::ScopedLock lock(_mutex);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
#else
std::unique_ptr<AbstractFactory> ptr(pAbstractFactory);
#endif // POCO_ENABLE_CPP11
typename FactoryMap::iterator it = _map.find(className);
if (it == _map.end())
@ -99,7 +95,7 @@ public:
else
throw ExistsException(className);
}
void unregisterClass(const std::string& className)
/// Unregisters the given class and deletes the instantiator
/// for the class.
@ -115,7 +111,7 @@ public:
}
else throw NotFoundException(className);
}
bool isClass(const std::string& className) const
/// Returns true iff the given class has been registered.
{
@ -129,7 +125,7 @@ private:
DynamicFactory& operator = (const DynamicFactory&);
typedef std::map<std::string, AbstractFactory*> FactoryMap;
FactoryMap _map;
mutable FastMutex _mutex;
};

View File

@ -58,11 +58,7 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec
std::string::size_type frac = str.length() - decSepPos - 1;
std::string::size_type ePos = str.find_first_of("eE");
#ifdef POCO_ENABLE_CPP11
std::unique_ptr<std::string> eStr;
#else
std::auto_ptr<std::string> eStr;
#endif
if (ePos != std::string::npos)
{
eStr.reset(new std::string(str.substr(ePos, std::string::npos)));
@ -201,7 +197,7 @@ std::string& floatToStr(std::string& str, float value, int precision, int width,
char buffer[POCO_MAX_FLT_STRING_LEN];
floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
str = buffer;
if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
replaceInPlace(str, '.', decSep);
@ -219,7 +215,7 @@ std::string& floatToFixedStr(std::string& str, float value, int precision, int w
char buffer[POCO_MAX_FLT_STRING_LEN];
floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
str = buffer;
if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
replaceInPlace(str, '.', decSep);
@ -263,9 +259,9 @@ std::string& doubleToStr(std::string& str, double value, int precision, int widt
char buffer[POCO_MAX_FLT_STRING_LEN];
doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value);
str = buffer;
if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
replaceInPlace(str, '.', decSep);
@ -282,9 +278,9 @@ std::string& doubleToFixedStr(std::string& str, double value, int precision, int
char buffer[POCO_MAX_FLT_STRING_LEN];
doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision);
str = buffer;
if (decSep && (decSep != '.') && (str.find('.') != std::string::npos))
replaceInPlace(str, '.', decSep);

View File

@ -28,16 +28,16 @@ namespace
Base()
{
}
virtual ~Base()
{
}
};
class A: public Base
{
};
class B: public Base
{
};
@ -57,26 +57,21 @@ DynamicFactoryTest::~DynamicFactoryTest()
void DynamicFactoryTest::testDynamicFactory()
{
DynamicFactory<Base> dynFactory;
dynFactory.registerClass<A>("A");
dynFactory.registerClass<B>("B");
assertTrue (dynFactory.isClass("A"));
assertTrue (dynFactory.isClass("B"));
assertTrue (!dynFactory.isClass("C"));
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<A> a(dynamic_cast<A*>(dynFactory.createInstance("A")));
std::auto_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#else
std::unique_ptr<A> a(dynamic_cast<A*>(dynFactory.createInstance("A")));
std::unique_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#endif // POCO_ENABLE_CPP11
assertNotNull(a.get());
assertNotNull(b.get());
try
{
dynFactory.registerClass<A>("A");
@ -85,18 +80,14 @@ void DynamicFactoryTest::testDynamicFactory()
catch (Poco::ExistsException&)
{
}
dynFactory.unregisterClass("B");
assertTrue (dynFactory.isClass("A"));
assertTrue (!dynFactory.isClass("B"));
try
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#else
std::unique_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#endif // POCO_ENABLE_CPP11
fail("unregistered - must throw");
}
catch (Poco::NotFoundException&)

View File

@ -49,7 +49,7 @@ namespace
{
}
};
class CustomFormatter: public Formatter
{
void format(const Message& msg, std::string& text)
@ -72,7 +72,7 @@ LoggingFactoryTest::~LoggingFactoryTest()
void LoggingFactoryTest::testBuiltins()
{
LoggingFactory& fact = LoggingFactory::defaultFactory();
AutoPtr<Channel> pConsoleChannel = fact.createChannel("ConsoleChannel");
#if defined(_WIN32) && !defined(_WIN32_WCE)
assertTrue (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
@ -82,10 +82,10 @@ void LoggingFactoryTest::testBuiltins()
AutoPtr<Channel> pFileChannel = fact.createChannel("FileChannel");
assertTrue (dynamic_cast<FileChannel*>(pFileChannel.get()) != 0);
AutoPtr<Channel> pSplitterChannel = fact.createChannel("SplitterChannel");
assertTrue (dynamic_cast<SplitterChannel*>(pSplitterChannel.get()) != 0);
try
{
AutoPtr<Channel> pUnknownChannel = fact.createChannel("UnknownChannel");
@ -94,10 +94,10 @@ void LoggingFactoryTest::testBuiltins()
catch (Poco::NotFoundException&)
{
}
AutoPtr<Formatter> pPatternFormatter = fact.createFormatter("PatternFormatter");
assertTrue (dynamic_cast<PatternFormatter*>(pPatternFormatter.get()) != 0);
try
{
AutoPtr<Formatter> pUnknownFormatter = fact.createFormatter("UnknownFormatter");
@ -111,11 +111,7 @@ void LoggingFactoryTest::testBuiltins()
void LoggingFactoryTest::testCustom()
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<LoggingFactory> fact(new LoggingFactory);
#else
std::unique_ptr<LoggingFactory> fact(new LoggingFactory);
#endif // POCO_ENABLE_CPP11
fact->registerChannelClass("CustomChannel", new Instantiator<CustomChannel, Channel>);
fact->registerFormatterClass("CustomFormatter", new Instantiator<CustomFormatter, Formatter>);

View File

@ -34,7 +34,7 @@ int main(int argc, char** argv)
{
HTTPStreamFactory::registerFactory();
FTPStreamFactory::registerFactory();
if (argc != 2)
{
Path p(argv[0]);
@ -47,11 +47,7 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif // POCO_ENABLE_CPP11
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
@ -59,6 +55,6 @@ int main(int argc, char** argv)
std::cerr << exc.displayText() << std::endl;
return 1;
}
return 0;
}

View File

@ -36,7 +36,7 @@ HTTPServerConnection::HTTPServerConnection(const StreamSocket& socket, HTTPServe
_stopped(false)
{
poco_check_ptr (pFactory);
_pFactory->serverStopped += Poco::delegate(this, &HTTPServerConnection::onServerStopped);
}
@ -67,7 +67,7 @@ void HTTPServerConnection::run()
{
HTTPServerResponseImpl response(session);
HTTPServerRequestImpl request(response, session, _pParams);
Poco::Timestamp now;
response.setDate(now);
response.setVersion(request.getVersion());
@ -76,16 +76,12 @@ void HTTPServerConnection::run()
response.set("Server", server);
try
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
#else
std::unique_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
#endif
if (pHandler.get())
{
if (request.getExpectContinue() && response.getStatus() == HTTPResponse::HTTP_OK)
response.sendContinue();
pHandler->handleRequest(request, response);
session.setKeepAlive(_pParams->getKeepAlive() && response.getKeepAlive() && session.canKeepAlive());
}

View File

@ -35,11 +35,11 @@ public:
_socket(socket)
{
}
~TCPConnectionNotification()
{
}
const StreamSocket& socket() const
{
return _socket;
@ -66,7 +66,7 @@ TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactor
if (!_pParams)
_pParams = new TCPServerParams;
if (_pParams->getMaxThreads() == 0)
_pParams->setMaxThreads(threadPool.capacity());
}
@ -108,18 +108,14 @@ void TCPServerDispatcher::run()
TCPConnectionNotification* pCNf = dynamic_cast<TCPConnectionNotification*>(pNf.get());
if (pCNf)
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#else
std::unique_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#endif // POCO_ENABLE_CPP11
poco_check_ptr(pConnection.get());
beginConnection();
pConnection->start();
endConnection();
}
}
FastMutex::ScopedLock lock(_mutex);
if (_stopped || (_currentThreads > 1 && _queue.empty()))
{
@ -135,7 +131,7 @@ namespace
static const std::string threadName("TCPServerConnection");
}
void TCPServerDispatcher::enqueue(const StreamSocket& socket)
{
FastMutex::ScopedLock lock(_mutex);
@ -179,14 +175,14 @@ void TCPServerDispatcher::stop()
int TCPServerDispatcher::currentThreads() const
{
FastMutex::ScopedLock lock(_mutex);
return _currentThreads;
}
int TCPServerDispatcher::maxThreads() const
{
FastMutex::ScopedLock lock(_mutex);
return _threadPool.capacity();
}
@ -194,7 +190,7 @@ int TCPServerDispatcher::maxThreads() const
int TCPServerDispatcher::totalConnections() const
{
FastMutex::ScopedLock lock(_mutex);
return _totalConnections;
}
@ -202,7 +198,7 @@ int TCPServerDispatcher::totalConnections() const
int TCPServerDispatcher::currentConnections() const
{
FastMutex::ScopedLock lock(_mutex);
return _currentConnections;
}
@ -210,7 +206,7 @@ int TCPServerDispatcher::currentConnections() const
int TCPServerDispatcher::maxConcurrentConnections() const
{
FastMutex::ScopedLock lock(_mutex);
return _maxConcurrentConnections;
}
@ -224,7 +220,7 @@ int TCPServerDispatcher::queuedConnections() const
int TCPServerDispatcher::refusedConnections() const
{
FastMutex::ScopedLock lock(_mutex);
return _refusedConnections;
}
@ -232,7 +228,7 @@ int TCPServerDispatcher::refusedConnections() const
void TCPServerDispatcher::beginConnection()
{
FastMutex::ScopedLock lock(_mutex);
++_totalConnections;
++_currentConnections;
if (_currentConnections > _maxConcurrentConnections)

View File

@ -79,16 +79,12 @@ void FTPStreamFactoryTest::testDownload()
uri.setPort(server.port());
uri.setPath("/test.txt;type=a");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@ -120,17 +116,13 @@ void FTPStreamFactoryTest::testList()
uri.setPort(server.port());
uri.setPath("/usr/guest/data;type=d");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "file1\r\nfile2\r\n");
}
@ -162,17 +154,13 @@ void FTPStreamFactoryTest::testUserInfo()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user:secret");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@ -205,17 +193,13 @@ void FTPStreamFactoryTest::testPasswordProvider()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
pStr.reset();
std::string s(dataStr.str());
assertTrue (s == "line1\r\nline2\r\n");
}
@ -239,11 +223,7 @@ void FTPStreamFactoryTest::testMissingPasswordProvider()
try
{
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
fail("no password provider - must throw");
}
catch (FTPException&)

View File

@ -44,11 +44,7 @@ void HTTPStreamFactoryTest::testNoRedirect()
HTTPStreamFactory factory;
URI uri("http://127.0.0.1/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);
@ -61,11 +57,7 @@ void HTTPStreamFactoryTest::testEmptyPath()
HTTPStreamFactory factory;
URI uri("http://127.0.0.1");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::SMALL_BODY);
@ -79,11 +71,7 @@ void HTTPStreamFactoryTest::testRedirect()
opener.registerStreamFactory("http", new HTTPStreamFactory);
URI uri("http://127.0.0.1/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(opener.open(uri));
#else
std::unique_ptr<std::istream> pStr(opener.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);
@ -95,11 +83,7 @@ void HTTPStreamFactoryTest::testProxy()
HTTPTestServer server;
HTTPStreamFactory factory("127.0.0.1", server.port());
URI uri("http://www.somehost.com/large");
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY);

View File

@ -50,7 +50,7 @@ public:
{
Poco::Net::initializeSSL();
}
~SSLInitializer()
{
Poco::Net::uninitializeSSL();
@ -64,7 +64,7 @@ int main(int argc, char** argv)
HTTPStreamFactory::registerFactory();
HTTPSStreamFactory::registerFactory();
FTPStreamFactory::registerFactory();
if (argc != 2)
{
Path p(argv[0]);
@ -74,7 +74,7 @@ int main(int argc, char** argv)
return 1;
}
// Note: we must create the passphrase handler prior Context
// Note: we must create the passphrase handler prior Context
SharedPtr<InvalidCertificateHandler> ptrCert = new ConsoleCertificateHandler(false); // ask the user via console
Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
SSLManager::instance().initializeClient(0, ptrCert, ptrContext);
@ -82,11 +82,7 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
@ -94,6 +90,6 @@ int main(int argc, char** argv)
std::cerr << exc.displayText() << std::endl;
return 1;
}
return 0;
}

View File

@ -47,11 +47,7 @@ void HTTPSStreamFactoryTest::testNoRedirect()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY);
@ -64,11 +60,7 @@ void HTTPSStreamFactoryTest::testEmptyPath()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::SMALL_BODY);
@ -81,11 +73,7 @@ void HTTPSStreamFactoryTest::testRedirect()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY);
@ -100,11 +88,7 @@ void HTTPSStreamFactoryTest::testProxy()
Application::instance().config().getInt("testsuite.proxy.port")
);
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str().length() > 0);

View File

@ -49,11 +49,7 @@ namespace
try
{
WebSocket ws(request, response);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<char> pBuffer(new char[_bufSize]);
#else
std::unique_ptr<char[]> pBuffer(new char[_bufSize]);
#endif // POCO_ENABLE_CPP11
int flags;
int n;
do
@ -86,7 +82,7 @@ namespace
private:
std::size_t _bufSize;
};
class WebSocketRequestHandlerFactory: public Poco::Net::HTTPRequestHandlerFactory
{
public:
@ -120,9 +116,9 @@ void WebSocketTest::testWebSocket()
Poco::Net::SecureServerSocket ss(0);
Poco::Net::HTTPServer server(new WebSocketRequestHandlerFactory, ss, new Poco::Net::HTTPServerParams);
server.start();
Poco::Thread::sleep(200);
HTTPSClientSession cs("127.0.0.1", ss.address().port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPResponse response;
@ -163,19 +159,19 @@ void WebSocketTest::testWebSocket()
assertTrue (n == payload.size());
assertTrue (payload.compare(0, payload.size(), buffer, 0, n) == 0);
assertTrue (flags == WebSocket::FRAME_TEXT);
payload = "Hello, universe!";
ws.sendFrame(payload.data(), (int) payload.size(), WebSocket::FRAME_BINARY);
n = ws.receiveFrame(buffer, sizeof(buffer), flags);
assertTrue (n == payload.size());
assertTrue (payload.compare(0, payload.size(), buffer, 0, n) == 0);
assertTrue (flags == WebSocket::FRAME_BINARY);
assertTrue (flags == WebSocket::FRAME_BINARY);
ws.shutdown();
n = ws.receiveFrame(buffer, sizeof(buffer), flags);
assertTrue (n == 2);
assertTrue ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE);
server.stop();
}
@ -189,7 +185,7 @@ void WebSocketTest::testWebSocketLarge()
server.start();
Poco::Thread::sleep(200);
HTTPSClientSession cs("127.0.0.1", ss.address().port());
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPResponse response;

View File

@ -48,7 +48,7 @@ public:
{
Poco::Net::initializeSSL();
}
~SSLInitializer()
{
Poco::Net::uninitializeSSL();
@ -62,7 +62,7 @@ int main(int argc, char** argv)
HTTPStreamFactory::registerFactory();
HTTPSStreamFactory::registerFactory();
FTPStreamFactory::registerFactory();
if (argc != 2)
{
Path p(argv[0]);
@ -79,11 +79,7 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif // POCO_ENABLE_CPP11
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
@ -91,6 +87,6 @@ int main(int argc, char** argv)
std::cerr << exc.displayText() << std::endl;
return 1;
}
return 0;
}

View File

@ -47,11 +47,7 @@ void HTTPSStreamFactoryTest::testNoRedirect()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY);
@ -64,11 +60,7 @@ void HTTPSStreamFactoryTest::testEmptyPath()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::SMALL_BODY);
@ -81,11 +73,7 @@ void HTTPSStreamFactoryTest::testRedirect()
HTTPSStreamFactory factory;
URI uri("https://127.0.0.1/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY);
@ -96,15 +84,11 @@ void HTTPSStreamFactoryTest::testProxy()
{
HTTPSTestServer server;
HTTPSStreamFactory factory(
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getInt("testsuite.proxy.port")
);
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assertTrue (ostr.str().length() > 0);

View File

@ -295,11 +295,7 @@ protected:
p.setBaseName(clazz);
}
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
#else
std::unique_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
#endif
if (!_outputDir.empty())
{

View File

@ -303,11 +303,7 @@ protected:
void parse(const std::string& file)
{
logger().information("Preprocessing " + file);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<Preprocessor> pPreProc(preprocess(file));
#else
std::unique_ptr<Preprocessor> pPreProc(preprocess(file));
#endif // POCO_ENABLE_CPP11
logger().information("Parsing " + file);
if (pPreProc->stream().good())
{