Hi Sean,
Thank you very much for this report. It helps fixing a bug.
Here is some explanation of your issues.
case 1 : virtual host attaches the application to "/docs/"
The Router tries to match the pattern defined ("/docs/") with the URI of
the current request. Therefore "/docs" does not match.
case 2 : virtual host attaches the application to "/docs"
Both URIs "/docs/" and "/docs" target your ".../docs/api/" directory.
As the default index file name is defined on the directory handler, both
URIs return the representation of the "index.html" file which defines an
HTML frameset with the following frames >>relative<< URLs :
- "overview-frame.html"
- "allclasses-frame.html"
- "overview-summary.html"
If your request URI ends with "/docs/", the relative URIs are correctly
interpreted. If your request URI ends with "/docs", they are not.
That's why an URI with no ending "/" that targets a true file directory
need to be redirected to the URI with the ending "/".
This bug has been fixed in SVN.
You can check yourself with the URL :
"http://java.sun.com/j2se/1.5.0/docs/api". It's automatically redirected
to "http://java.sun.com/j2se/1.5.0/docs/api/".
Best regards,
Thierry Boileau
Sean Landis a écrit :
I'm surprised by some behavior I'm seeing. I ran a slightly modified version of
Part06.java that looks like this:
public class Part06 implements Constants {
public static final String ROOT_URI =
"file:////home/slandis/restlet-1.0rc3/docs/api/";
public static void main(String[] args) throws Exception {
// Create a component
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.FILE);
// Create an application
Application application = new Application(component.getContext()) {
@Override
public Restlet createRoot() {
return new Directory(getContext(), ROOT_URI);
}
};
// Attach the application to the component and start it
component.getDefaultHost().attach("", application);
component.start();
}
}
And if I use "http://localhost:8182" then the javadoc is correctly displayed.
I modified the last bit to create a virtual host instead using the
default host:
// Attach the application to the component and start it
VirtualHost vh1 = new VirtualHost(component.getContext());
vh1.setHostDomain("localhost");
vh1.attach("/docs/", application);
component.getHosts().add(vh1);
component.start();
And it works fine for "http://localhost:8182/docs/" but does not resolve
"http://localhost:8182/docs" which I would expect.
Next I change the route URI in the attach() like this:
vh1.attach("/docs", application);
and now "http://localhost:8182/docs/" works but "http://localhost:8182/docs"
diplays the frames but within the three frames says:
The server has not found anything matching the request URI
You can get technical details here.
Please continue your visit at our home page.
I flushed my cache before each test ;-)
I would have expected the final case to have "http://localhost:8182/docs"
work and ".../docs/" not work. I'm surprised that the URI is interacting
strangely and I don't know if it's the virtual host or Directory, or both.
Sean