Merge branch 'poco-1.10.0'

This commit is contained in:
Günter Obiltschnig
2020-01-27 10:47:26 +01:00
2 changed files with 65 additions and 83 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -69,7 +69,7 @@ and a pointer to a member function. The event can be fired by calling
#include <iostream> #include <iostream>
using Poco::BasicEvent; using Poco::BasicEvent;
using Poco::Delegate; using Poco::delegate;
class Source class Source
{ {
@@ -96,13 +96,11 @@ and a pointer to a member function. The event can be fired by calling
Source source; Source source;
Target target; Target target;
source.theEvent += Delegate<Target, int>( source.theEvent += delegate(&target, &Target::onEvent);
&target, &Target::onEvent);
source.fireEvent(42); source.fireEvent(42);
source.theEvent -= Delegate<Target, int>( source.theEvent -= delegate(&target, &Target::onEvent);
&target, &Target::onEvent);
return 0; return 0;
} }
@@ -315,12 +313,11 @@ server.
{ {
} }
void handleRequest(HTTPServerRequest& request, void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
HTTPServerResponse& response)
{ {
Application& app = Application::instance(); Application& app = Application::instance();
app.logger().information("Request from " app.logger().information("Request from %s",
+ request.clientAddress().toString()); request.clientAddress().toString());
Timestamp now; Timestamp now;
std::string dt(DateTimeFormatter::format(now, _format)); std::string dt(DateTimeFormatter::format(now, _format));
@@ -350,8 +347,7 @@ server.
{ {
} }
HTTPRequestHandler* createRequestHandler( HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
const HTTPServerRequest& request)
{ {
if (request.getURI() == "/") if (request.getURI() == "/")
return new TimeRequestHandler(_format); return new TimeRequestHandler(_format);
@@ -365,15 +361,6 @@ server.
class HTTPTimeServer: public Poco::Util::ServerApplication class HTTPTimeServer: public Poco::Util::ServerApplication
{ {
public:
HTTPTimeServer(): _helpRequested(false)
{
}
~HTTPTimeServer()
{
}
protected: protected:
void initialize(Application& self) void initialize(Application& self)
{ {
@@ -381,11 +368,6 @@ server.
ServerApplication::initialize(self); ServerApplication::initialize(self);
} }
void uninitialize()
{
ServerApplication::uninitialize();
}
void defineOptions(OptionSet& options) void defineOptions(OptionSet& options)
{ {
ServerApplication::defineOptions(options); ServerApplication::defineOptions(options);
@@ -398,8 +380,7 @@ server.
this, &HTTPTimeServer::handleHelp))); this, &HTTPTimeServer::handleHelp)));
} }
void handleHelp(const std::string& name, void handleHelp(const std::string& name, const std::string& value)
const std::string& value)
{ {
HelpFormatter helpFormatter(options()); HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName()); helpFormatter.setCommand(commandName());
@@ -415,14 +396,15 @@ server.
{ {
if (!_helpRequested) if (!_helpRequested)
{ {
unsigned short port = (unsigned short) unsigned short port = static_cast<unsigned short>(
config().getInt("HTTPTimeServer.port", 9980); config().getInt("HTTPTimeServer.port", 9980));
std::string format( std::string format(config().getString(
config().getString("HTTPTimeServer.format", "HTTPTimeServer.format",
DateTimeFormat::SORTABLE_FORMAT)); DateTimeFormat::SORTABLE_FORMAT));
ServerSocket svs(port); ServerSocket svs(port);
HTTPServer srv(new TimeRequestHandlerFactory(format), HTTPServer srv(
new TimeRequestHandlerFactory(format),
svs, new HTTPServerParams); svs, new HTTPServerParams);
srv.start(); srv.start();
waitForTerminationRequest(); waitForTerminationRequest();
@@ -432,7 +414,7 @@ server.
} }
private: private:
bool _helpRequested; bool _helpRequested = false;
}; };
int main(int argc, char** argv) int main(int argc, char** argv)