Project

General

Profile

Actions

Bug #3245

closed

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

Added by Alan Finley over 10 years ago. Updated about 9 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

Actions #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.

Actions #2

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?

Actions #3

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

Actions #4

Updated by Benoit Daccache over 9 years ago

  • Status changed from InProgress to Resolved
Actions #5

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions #6

Updated by Koen Deforche about 9 years ago

  • Target version set to 3.3.5
Actions

Also available in: Atom PDF