Project

General

Profile

Problem with progressive-bootstrap set to true and internalPath returning favicon.ico

Added by Jeff Flesher almost 11 years ago

Here is the whole app to demonstrate this behaviour:

#include <Wt/WApplication>
#include <Wt/WServer>
#include <Wt/WText>
#include <Wt/WLink>
#include <Wt/WPushButton>

class ProgressiveBootstrap : public Wt::WApplication
{
    public:
        ProgressiveBootstrap(const Wt::WEnvironment& env) : Wt::WApplication(env)
        {
            Wt::WPushButton* button = new Wt::WPushButton("Next", root());
            button->setLink(Wt::WLink(Wt::WLink::InternalPath, "/navigation/anchor"));
            internalPathChanged().connect(this, &ProgressiveBootstrap::InternalPathChange);
            // Make Path change with internalPath
            InternalPathChange(internalPath());
            /*
             * Create two links to internal paths.
             */
            Wt::WContainerWidget *container = new Wt::WContainerWidget(root());
            new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/navigation/shop"), "Shop", container);
            new Wt::WText(" ", container);
            new Wt::WAnchor(Wt::WLink(Wt::WLink::InternalPath, "/navigation/eat"), "Eat", container);

            /*
             * Handle the internal path events.
             */
            Wt::WText *out = new Wt::WText(container);
            out->setInline(false);

            Wt::WApplication *app = Wt::WApplication::instance();

            app->internalPathChanged().connect(std::bind([=] () { handlePathChange(out); }));

            handlePathChange(out);

        }

        void InternalPathChange(const std::string& thePath)
        {
            Wt::log("path") << thePath;
            new Wt::WText(thePath);
        }

        void handlePathChange(Wt::WText *out)
        {
            Wt::WApplication *app = Wt::WApplication::instance();
            Wt::log("handlePathChange") << app->internalPath();

            if      (app->internalPath() == "/navigation/shop")out->setText("<p>Currently shopping.</p>");
            else if (app->internalPath() == "/navigation/eat")out->setText("<p>Needed some food, eating now!</p>");
            else    out->setText("<p><i>Idle.</i></p>");
        }
};


Wt::WApplication* CreateApp(const Wt::WEnvironment& env)
{
    return new ProgressiveBootstrap(env);
}


int main(int argc, char* argv[])
{
    // Note: this works fine: return Wt::WRun(argc, argv, CreateApp);
    // Does that mean I should not use the below method?

    try
    {
        Wt::WServer server(argv[0]);
        server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION);
        server.addEntryPoint(Wt::Application, boost::bind(&CreateApp,  _1), "", "favicon.ico");
        if (server.start())
        {
            Wt::WServer::waitForShutdown();
            server.stop();
        }
    }
    catch (Wt::WServer::Exception& e)
    {
        std::cerr << e.what() << std::endl;
    }
    catch (std::exception &e)
    {
        std::cerr << "exception: " << e.what() << std::endl;
    }

}

true

Logs:

[2014-Aug-24 14:37:30.146936] 7486 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/mnt/storage/jflesher/FileShare/Code/Wt/0-Examples/progressive-bootstrap/build-progressive-bootstrap-Desktop-Debug/progressive-bootstrap.wt')"
[2014-Aug-24 14:37:30.148360] 7486 - [info] "WServer/wthttp: initializing built-in wthttpd"
[2014-Aug-24 14:37:30.148939] 7486 - [info] "wthttp: started server: http://0.0.0.0:8088"
[2014-Aug-24 14:37:32.906461] 7486 - [info] "Wt: session created (#sessions = 1)"
[2014-Aug-24 14:37:32.906755] 7486 [/ww 8exO13ZuOJoUTmxI] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
[2014-Aug-24 14:37:32.907986] 7486 [/ww 8exO13ZuOJoUTmxI] [path] "/navigation/anchor"
[2014-Aug-24 14:37:32.908166] 7486 [/ww 8exO13ZuOJoUTmxI] [handlePathChange] "/navigation/anchor"
127.0.0.1 - - [2014-Aug-24 14:37:32.910263] "GET /ww/navigation/anchor HTTP/1.1" 200 3180
[2014-Aug-24 14:37:32.910341] 7486 - [info] "WebRequest: took 4.024ms"
127.0.0.1 - - [2014-Aug-24 14:37:32.922683] "GET /resources/themes/default/wt.css HTTP/1.1" 304 0
127.0.0.1 - - [2014-Aug-24 14:37:32.922683] "GET /resources/webkit-transitions.css HTTP/1.1" 304 0
127.0.0.1 - - [2014-Aug-24 14:37:33.007261] "GET /ww?wtd=8exO13ZuOJoUTmxI&sid=-610999544&webGL=true&tz=-420&htmlHistory=true&deployPath=%2Fww&request=script&rand=1265103407 HTTP/1.1" 200 34705
[2014-Aug-24 14:37:33.007335] 7486 - [info] "WebRequest: took 6.333ms"
[2014-Aug-24 14:37:33.024564] 7486 - [info] "Wt: session created (#sessions = 2)"
[2014-Aug-24 14:37:33.024684] 7486 [/ww xNPXJWWRMn7OyKUc] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
[2014-Aug-24 14:37:33.025086] 7486 [/ww xNPXJWWRMn7OyKUc] [path] "/navigation/favicon.ico"
[2014-Aug-24 14:37:33.025149] 7486 [/ww xNPXJWWRMn7OyKUc] [handlePathChange] "/navigation/favicon.ico"
127.0.0.1 - - [2014-Aug-24 14:37:33.025921] "GET /ww/navigation/favicon.ico HTTP/1.1" 200 3180
[2014-Aug-24 14:37:33.025944] 7486 - [info] "WebRequest: took 1.462ms"
127.0.0.1 - - [2014-Aug-24 14:37:33.115397] "POST /ww?wtd=8exO13ZuOJoUTmxI HTTP/1.1" 200 50
[2014-Aug-24 14:37:33.115443] 7486 - [info] "WebRequest: took 0.38ms"
[2014-Aug-24 14:37:34.831637] 7486 - [info] "Wt: session created (#sessions = 3)"
[2014-Aug-24 14:37:34.831824] 7486 [/ww kZIU0AfaKoFB0AkP] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
[2014-Aug-24 14:37:34.832535] 7486 [/ww kZIU0AfaKoFB0AkP] [path] "/navigation/favicon.ico"
[2014-Aug-24 14:37:34.832653] 7486 [/ww kZIU0AfaKoFB0AkP] [handlePathChange] "/navigation/favicon.ico"
127.0.0.1 - - [2014-Aug-24 14:37:34.834090] "GET /ww/navigation/favicon.ico HTTP/1.1" 200 3181
[2014-Aug-24 14:37:34.834133] 7486 - [info] "WebRequest: took 2.613ms"
[2014-Aug-24 14:37:34.864548] 7486 [/ww 8exO13ZuOJoUTmxI] [handlePathChange] "/navigation/shop"
[2014-Aug-24 14:37:34.864652] 7486 [/ww 8exO13ZuOJoUTmxI] [path] "/navigation/shop"

false

Logs:

[2014-Aug-24 14:36:22.279980] 7437 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/mnt/storage/jflesher/FileShare/Code/Wt/0-Examples/progressive-bootstrap/build-progressive-bootstrap-Desktop-Debug/progressive-bootstrap.wt')"
[2014-Aug-24 14:36:22.280990] 7437 - [info] "WServer/wthttp: initializing built-in wthttpd"
[2014-Aug-24 14:36:22.281322] 7437 - [info] "wthttp: started server: http://0.0.0.0:8088"
[2014-Aug-24 14:36:24.649440] 7437 - [info] "Wt: session created (#sessions = 1)"
[2014-Aug-24 14:36:24.649714] 7437 [/ww 36AKdvrui2Sjm3Mf] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
127.0.0.1 - - [2014-Aug-24 14:36:24.651315] "GET /ww/navigation/anchor HTTP/1.1" 200 2214
[2014-Aug-24 14:36:24.651392] 7437 - [info] "WebRequest: took 2.117ms"
[2014-Aug-24 14:36:24.759847] 7437 [/ww 36AKdvrui2Sjm3Mf] [path] "/navigation/anchor"
[2014-Aug-24 14:36:24.759975] 7437 [/ww 36AKdvrui2Sjm3Mf] [handlePathChange] "/navigation/anchor"
127.0.0.1 - - [2014-Aug-24 14:36:24.760364] "GET /ww?wtd=36AKdvrui2Sjm3Mf&request=style HTTP/1.1" 200 91
[2014-Aug-24 14:36:24.760425] 7437 - [info] "WebRequest: took 92.412ms"
127.0.0.1 - - [2014-Aug-24 14:36:24.762732] "GET /resources/themes/default/wt.css HTTP/1.1" 304 0
127.0.0.1 - - [2014-Aug-24 14:36:24.762798] "GET /resources/webkit-transitions.css HTTP/1.1" 304 0
127.0.0.1 - - [2014-Aug-24 14:36:24.769759] "GET /ww?wtd=36AKdvrui2Sjm3Mf&sid=-1009795358&webGL=true&tz=-420&htmlHistory=true&deployPath=%2Fww&request=script&rand=3643513189 HTTP/1.1" 200 35166
[2014-Aug-24 14:36:24.769888] 7437 - [info] "WebRequest: took 10.67ms"
[2014-Aug-24 14:36:24.847348] 7437 - [info] "Wt: session created (#sessions = 2)"
[2014-Aug-24 14:36:24.847522] 7437 [/ww jTRQvMuJ3BZ8rBL2] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
127.0.0.1 - - [2014-Aug-24 14:36:24.847712] "POST /ww?wtd=36AKdvrui2Sjm3Mf HTTP/1.1" 200 51
[2014-Aug-24 14:36:24.847738] 7437 - [info] "WebRequest: took 0.221ms"
127.0.0.1 - - [2014-Aug-24 14:36:24.848173] "GET /ww/navigation/favicon.ico HTTP/1.1" 200 2215
[2014-Aug-24 14:36:24.848202] 7437 - [info] "WebRequest: took 0.962ms"
[2014-Aug-24 14:36:26.291424] 7437 - [info] "Wt: session created (#sessions = 3)"
[2014-Aug-24 14:36:26.291612] 7437 [/ww KavmXBITggXi405H] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
127.0.0.1 - - [2014-Aug-24 14:36:26.292710] "GET /ww/navigation/favicon.ico HTTP/1.1" 200 2211
[2014-Aug-24 14:36:26.292755] 7437 - [info] "WebRequest: took 1.444ms"
[2014-Aug-24 14:36:26.323732] 7437 [/ww 36AKdvrui2Sjm3Mf] [handlePathChange] "/navigation/shop"
[2014-Aug-24 14:36:26.323844] 7437 [/ww 36AKdvrui2Sjm3Mf] [path] "/navigation/shop"

Replies (1)

    (1-1/1)