Hi Koen!
Post by Koen DeforcheHey,
...
Post by K. FrankLet me summarize my set up: I have a subdirectory of my current
working directory called static_links. In it is a file, say, link1.html.
...
http://localhost/mixed_links/static_links/link1.html
does not successfully link to the file. The ";" syntax does have an
effect, however. If I deploy with "--docroot="."", the above link returns
a 404, while if I deploy with "--docroot=.;/static_links", the above link
gets processed as an internal path in my application (but wthttpd does
not serve the link1.html file as static content).
- with "--deploy-path=/mixed_links/ --docroot="."", Wt will interpret this
request as an internal path (as it matches the deploy-path of an
application)
This isn't what I see -- I've tried to repeat the test quite carefully.
As far as I can tell, the link:
http://localhost/mixed_links/static_links/link1.html
is not interpreted as an internal path.
(Actually, I used http://localhost/mixed_links/static_links/sl1.html
in my test, as you will see in the notes, below.)
I really do get a 404. (I've tried this both on ie and opera.) I also
log WApplication::internalPathChanged(), and it doesn't fire when
I click on the link.
Before I launch into the details, let me mention again that my Wt
installation is wt-3.3.3, and both it and my Wt application were built
with mingw-w64 on 64-bit windows 7.
Here are some more detailed notes of my test:
First, here's what happens:
enter "landing page" link in browser
http://localhost/mixed_links/
--> home page (built by my WApplication code)
click on
link to sl1 (as /mixed_links/static_links/sl1.html)
http://localhost/mixed_links/static_links/sl1.html (<-- how it
appears in browser's address entry)
--> 404
browser back button
--> back to home page
click on
link to ip1
http://localhost/mixed_links/?_=/internal_paths/ip1 (<-- how it
appears in browser's address entry)
--> internalPathChanged fires, and my code displays the ip1 page
(As I understand it, I get the "?_=" in the link because my
deploy-path ended in "/".)
Some relevant code snippets from my WApplication:
class MixedLinksApp : public WApplication {
public:
MixedLinksApp (const WEnvironment& env) : WApplication (env) {
cout << "MixedLinksApp::MixedLinksApp ..." << endl;
internalPathChanged().connect (this,
MixedLinksApp::onInternalPathChanged);
makePage (true);
}
void onInternalPathChanged() {
cout << "onInternalPathChanged ..." << endl; // <-- log all
internalPathChanged() signals
makePage (false);
}
void makePage (bool newApp) {
cout << "makePage: newApp = " << newApp << endl;
cout << " appRoot() = " << appRoot() << endl;
cout << " docRoot() = " << docRoot() << endl;
// ...
// *** here's where I create the internal-path ip1 link
t = new WText ("link to <a href='#/internal_paths/ip1'>ip1</a>");
t->setInternalPathEncoding (true);
// *** here's where I create the static-content sl1 link
t = new WText ("link to <a
href='/mixed_links/static_links/sl1.html'>sl1</a> (as
/mixed_links/static_links/sl1.html)");
// t->setInternalPathEncoding (true); <-- I tried both way;
setInternalPathEncoding didn't matter
Lastly, here's the console log. This is both what Wt writes out itself,
and the output from the cout calls in my code. Note that clicking the
ip1 link causes my code to log (and process) the internalPathChanged()
signal, whereas clicking on the sl1 link does not seem to cause the
internalPathChanged() signal to fire. Also, Wt's logging does seem to
show Wt issuing a 404 for the sl1 link.
C:\test>mixed_links --http-address=0.0.0.0 --http-port=80
--deploy-path=/mixed_links/ --docroot="."
Option no-compression is implied because wthttp was built without
zlib support.
[2016-Jul-12 10:50:04.885049] 9916 - [info] "config: reading Wt
config file: c:/witty/wt_config.xml (location = 'mixed_links')"
Option no-compression is implied because wthttp was built without
zlib support.
[2016-Jul-12 10:50:04.885049] 9916 - [info] "WServer/wthttp:
initializing built-in wthttpd"
[2016-Jul-12 10:50:04.885049] 9916 - [info] "wthttp: started
server: http://0.0.0.0:80"
[2016-Jul-12 10:50:23.599482] 9916 - [info] "Wt: session created
(#sessions = 1)"
[2016-Jul-12 10:50:23.599482] 9916 [/mixed_links/ UhtrN8ZHQZnqsFS8]
[info] "WEnvironment: UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64;
Trident/7.0;
MALC; rv:11.0) like Gecko"
127.0.0.1 - - [2016-Jul-12 10:50:23.599482] "GET /mixed_links/
HTTP/1.1" 200 4665
[2016-Jul-12 10:50:23.599482] 9916 - [info] "WebRequest: took 0ms"
MixedLinksApp::MixedLinksApp ...
[2016-Jul-12 10:50:23.713682] 9916 [/mixed_links/ UhtrN8ZHQZnqsFS8]
[warning] "WApplication: Deploy-path ends with '/', using /?_= for
internal paths"
makePage: newApp = 1
appRoot() =
docRoot() = .
environment().deploymentPath() = /mixed_links/
environment().internalPath() =
internalPath() = /
url() = /mixed_links/?wtd=UhtrN8ZHQZnqsFS8
bookmarkUrl() = ?
127.0.0.1 - - [2016-Jul-12 10:50:23.718682] "GET
/mixed_links/?wtd=UhtrN8ZHQZnqsFS8&request=style HTTP/1.1" 200 116
[2016-Jul-12 10:50:23.718682] 9916 - [info] "WebRequest: took 103.6ms"
127.0.0.1 - - [2016-Jul-12 10:50:23.718682] "GET
/mixed_links/resources/themes/default/wt.css HTTP/1.1" 404 85
127.0.0.1 - - [2016-Jul-12 10:50:23.718682] "GET
/mixed_links/?wtd=UhtrN8ZHQZnqsFS8&sid=-466592228&webGL=true&tz=-240&htmlHistory=true&deployPath=%2Fm
ixed_links%2F&request=script&rand=3300683377 HTTP/1.1" 200 105778
1[27.0.0.1 - - [2016-Jul-12 10:50:23.718682] "GET
/mixed_links/resources/transitions.css HTTP/1.1" 404 852016-Jul-12
10:50:23.718682] 9916 - [info] "W
ebRequest: took 5ms"
127.0.0.1 - - [2016-Jul-12 10:50:23.874184] "POST
/mixed_links/?wtd=UhtrN8ZHQZnqsFS8 HTTP/1.1" 200 30
[2016-Jul-12 10:50:23.876684] 9916 - [info] "WebRequest: took 5ms"
127.0.0.1 - - [2016-Jul-12 10:51:07.529267] "GET
/mixed_links/static_links/sl1.html HTTP/1.1" 404 85
onInternalPathChanged ...
makePage: newApp = 0
appRoot() =
docRoot() = .
environment().deploymentPath() = /mixed_links/
environment().internalPath() =
internalPath() = /internal_paths/ip1
url() = /mixed_links/?wtd=UhtrN8ZHQZnqsFS8
bookmarkUrl() = ?_=/internal_paths/ip1
127.0.0.1 - - [2016-Jul-12 10:52:22.178807] "POST
/mixed_links/?wtd=UhtrN8ZHQZnqsFS8 HTTP/1.1" 200 1838
[2016-Jul-12 10:52:22.178807] 9916 - [info] "WebRequest: took 0ms"
Please let me know if you see anything suspicious or unexpected
in the above. Again, this is not a problem for me -- I don't mind
the 404. I'm just experimenting, and trying to understand how Wt
works and how to use it.
Post by Koen DeforcheI think Wt is quite flexible in terms of URL handling (in spite of being
unconventional).
I hope the clarifications help.
Yes, thanks very much.
Best regards.
K. Frank