On Sat, Oct 17, 2009 at 6:33 AM, OvermindDL1 <[email protected]> wrote: > Greetings, > > I have a url: > > http://localhost/ > > That displays a page that just has a login screen (takes a username > and a password). > When login is clicked the server then destroys that container, and > creates a container with a menu (with its menu root path set to "/"). > It creates an item that is another container that has its own menu as > well (base root path for that menu is "/user/") that displays the user > information. > > When the browser supports javascript, when a person logs in it then > automatically goes to the first menu item (which is the user page), > then that user page goes to its first menu item (this is all in one > request, you all certainly know how menu's work better then I do), > which then loads the user information (currently a blank page). > > When the browser has javascript disabled (which will happen in the > place this will be used at times) it then causes an infinite redirect > causing the browser to abort with the standard "detected that the > server is redirecting the request for this address in a way that will > never complete." type error. Upon debugging through the server, it > appears that at in webrenderer.c starting on line 693 (I am using the > latest git trunk as of about a week ago) is this section of code (nice > mix of tabs and space, looks really odd in my IDE :) ) is this: > > if (!app->environment().ajax() > && (response.requestMethod() == "POST" > || (app->internalPathIsChanged_ > && app->oldInternalPath_ != app->newInternalPath_))) > session_.redirect(app->bookmarkUrl(app->newInternalPath_)); > > Well, the browser just so happens to not support ajax, so this if is > taken. The request is GET, not POST, however the > internalPathIsChanged boolean is set to true, and oldInternalPath_ > does not euqal newInternalPath_ since oldInternalPath_ == "/" and > newInternalPath_ == "/user/info/", and so it calls for a redirect. > The interesting bit is, oldInternalPath_ is *never* set to > newInternalPath_ in any of this redirect calls, and > internalPathIsChanged is *never* set to false because, guess what, the > code right underneath the above lines: > > std::string redirect = session_.getRedirect(); > > if (!redirect.empty()) { > std::cerr << "Redirect: " << redirect << std::endl; > response.setRedirect(redirect); > return; > } > > And the line that resets the internalPathIsChanged boolean to false as > at the very end of that function, many many many lines down. > > Also, the oldInternalPath_ is only ever set, in the entire source, in > WApplication::setInternalPath, which is is never called during any of > the infinite redirect loops at any point time. > > Thus it seems that there are two distinct issues that are contributing > to the infinite redirect. I do not know which to fix, or even how to > fix them (still learning the Wt code). > > Does anyone have any fixes? Any work-arounds? Anything? > > > > > > > > websession.c starting on line 1181 (I am using the latest git trunk > as of about a week ago) is this section of code (nice mix of tabs and > space, looks really odd in my IDE :) ): > if (event.responseType == WebRenderer::Page) { > if (!request.pathInfo().empty()) > app_->changeInternalPath(request.pathInfo()); > else { > const std::string *hashE = request.getParameter("_"); > if (hashE) > app_->changeInternalPath(*hashE); > } > > It end up following the else of the second level if so > app_->changeInternalPath(*hashE); (where hashE == "/user/info") ends > up getting called. This
After spending a while making a reduced test case, I found you do not even need to have it built after the fact, but just build the issue straight out, and doing it this way shows the same error in ajax mode as normal mode (hence, you do not need to disabled javascript to see how this breaks), and you only even need just one menu and it still breaks. The complete test case is at the bottom of this email. Just compile and run and open a browser to http://localhost/Broken/ and see what happens. I also have the server already compiled and running (unless if I am in the middle of recompiling to test other things) at http://overminddl1.no-ip.info:8030/Broken/ if anyone feels up for seeing the exact code I post below. So, does anyone see what I am doing wrong, or is this a bug in Wt? P.S. I found something interesting while reducing this. If I remove the "menu->setRenderAsList(true);" line or if I remove "menu->setInternalPathEnabled("/");" line, then it works. I might understand why removing the setInternalPathEnabled works, but why on earth would removing the setRenderAsList line do anything like that? #include <Wt/WServer> #include <Wt/WMenu> #include <Wt/WStackedWidget> #include <Wt/WText> #include <Wt/WVBoxLayout> using namespace Wt; WApplication *createBrokenApplication(const WEnvironment& env) { WApplication *app = new WApplication(env); // Main page with menu WContainerWidget *container = new WContainerWidget(app->root()); { WVBoxLayout *smc = new WVBoxLayout(container); smc->setSpacing(0); smc->setContentsMargins(0,0,0,0); WStackedWidget *subContentsStack = new WStackedWidget(); WMenu *menu = new WMenu(subContentsStack, Horizontal); menu->setRenderAsList(true); menu->setInternalPathEnabled("/"); menu->addItem("Info", new WText("TODO: Add in user account options, controls, etc...")); smc->addWidget(menu, 0); smc->addWidget(subContentsStack, 1); } return app; } int main(int argc, char **argv) { WServer server(argv[0]); server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION); server.addEntryPoint(Application, createBrokenApplication, "/Broken/"); if(server.start()) { WServer::waitForShutdown(); server.stop(); } } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
