Actions
Bug #3245
closedWApplication::docRoot returns empty string after WServer::post
Start date:
06/02/2014
Due date:
% Done:
0%
Estimated time:
Description
A short example:
void postSig()
{
Wt::WApplication::UpdateLock lock(wApp);
if (lock)
{
qDebug() << "postSig" << "docroot:" << wApp->docRoot().c_str();
}
else
{
qDebug() << "something terrible";
}
}
void sendSig()
{
qDebug() << "sendSig" << "docroot:" << wApp->docRoot().c_str();
Wt::WServer::instance()->post(wApp->sessionId(), boost::bind(&postSig));
}
Wt::WApplication* createApplication(const Wt::WEnvironment& env)
{
Wt::WApplication *app = new Wt::WApplication(env);
app->enableUpdates(true);
qDebug() << "create" << "docroot:" << app->docRoot().c_str();
Wt::WPushButton *b = new Wt::WPushButton("send sig", app->root());
b->clicked().connect(boost::bind(&sendSig));
return app;
}
WApplication::docRoot
returns empty string in the postSig
function. In other functions it returns correct value.
I use Wt 3.3.1
Updated by Wim Dumon over 10 years ago
That's because docroot is reported to Wt from the HTTP server together with the request. However, when post()ed, there's no active request and Wt can't query docroot. Thus it returns an empty string.
BR,
Wim.
Updated by Alan Finley over 10 years ago
I thought that every Wt web session is initialized with some specific docroot value. Does it make sense to save it inside WApplication after it was initialized and not to get it every time through requests?
Updated by Koen Deforche over 9 years ago
- Status changed from New to InProgress
- Assignee set to Benoit Daccache
Add cache the docRoot to the WebSession so that this works in method sent from WServer::post()
Updated by Benoit Daccache over 9 years ago
- Status changed from InProgress to Resolved
Updated by Koen Deforche about 9 years ago
- Status changed from Resolved to Closed
Actions