mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-25 06:36:37 +01:00
added support to get client id
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
#include "Poco/Net/HTTPServerResponse.h"
|
||||
#include "Poco/URI.h"
|
||||
#include "Poco/ThreadLocal.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@@ -59,6 +60,7 @@ const std::string RequestHandler::KEY_ID("id");
|
||||
const std::string RequestHandler::KEY_EVID("evId");
|
||||
|
||||
|
||||
|
||||
RequestHandler::RequestHandler(WebApplication& app):
|
||||
_app(app)
|
||||
{
|
||||
@@ -72,7 +74,7 @@ RequestHandler::~RequestHandler()
|
||||
|
||||
void RequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
_app.attachToThread();
|
||||
_app.attachToThread(request);
|
||||
Poco::Net::NameValueCollection args;
|
||||
parseRequest(request, args);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Poco/WebWidgets/WebApplication.h"
|
||||
#include "Poco/WebWidgets/RequestProcessor.h"
|
||||
#include "Poco/Net/HTMLForm.h"
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -44,6 +45,7 @@ namespace WebWidgets {
|
||||
|
||||
|
||||
Poco::ThreadLocal<WebApplication*> WebApplication::_pInstance;
|
||||
Poco::ThreadLocal<std::string> WebApplication::_clientMachine;
|
||||
|
||||
|
||||
WebApplication::WebApplication(const Poco::URI& uri,ResourceManager::Ptr pRM):
|
||||
@@ -53,7 +55,8 @@ WebApplication::WebApplication(const Poco::URI& uri,ResourceManager::Ptr pRM):
|
||||
_uri(uri)
|
||||
{
|
||||
poco_check_ptr (pRM);
|
||||
attachToThread();
|
||||
*_pInstance = this;
|
||||
*_clientMachine = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +79,10 @@ void WebApplication::setCurrentPage(Page::Ptr pPage)
|
||||
}
|
||||
|
||||
|
||||
void WebApplication::attachToThread()
|
||||
void WebApplication::attachToThread(Poco::Net::HTTPServerRequest& request)
|
||||
{
|
||||
*_pInstance = this;
|
||||
*_clientMachine = request.getHost();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +94,12 @@ WebApplication& WebApplication::instance()
|
||||
}
|
||||
|
||||
|
||||
std::string WebApplication::clientHostName()
|
||||
{
|
||||
return *_clientMachine;
|
||||
}
|
||||
|
||||
|
||||
void WebApplication::registerFormProcessor(const std::string& fieldName, RequestProcessor* pProc)
|
||||
{
|
||||
std::pair<RequestProcessorMap::iterator, bool> res = _requestProcessorMap.insert(std::make_pair(fieldName, pProc));
|
||||
|
||||
Reference in New Issue
Block a user