Project

General

Profile

Actions

Bug #3245

closed
AF BD

WApplication::docRoot returns empty string after WServer::post

Bug #3245: WApplication::docRoot returns empty string after WServer::post

Added by Alan Finley over 12 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Benoit Daccache
Target version:
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

WD Updated by Wim Dumon over 12 years ago Actions #1

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.

AF Updated by Alan Finley over 12 years ago Actions #2

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?

KD Updated by Koen Deforche over 11 years ago Actions #3

  • 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()

BD Updated by Benoit Daccache over 11 years ago Actions #4

  • Status changed from InProgress to Resolved

KD Updated by Koen Deforche almost 11 years ago Actions #5

  • Status changed from Resolved to Closed

KD Updated by Koen Deforche almost 11 years ago Actions #6

  • Target version set to 3.3.5
Actions

Also available in: PDF Atom