[
https://issues.apache.org/jira/browse/VFS-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13589360#comment-13589360
]
Jean-Marc Borer commented on VFS-199:
-------------------------------------
Hello guys,
After testing the patch I had issues browsing HTTP directories because of the
missing trailing "/". When redirection is turned on, it works. However there is
a side effect when you enabled webdav for the same resources.
Basically when you build an URL like http://localhost/root/dir1 where dir1 is
actually a directory, you're web server will usually redirect to
http://localhost/root/dir1/. The same happens with VFS and webdav requests, but
the issue here is that webdav doesn't suppport redirection.
The trick here is to
1) turn off redirection
2) add a trailing "/" for HTTP directory browsing requests only
This seems seems to work not too badly: in the HttpFileObject's setupMethod, I
add a trailing slash to the requeset path when VFS.isUriStyle is false and the
file type is supposed to be a folder.
protected void setupMethod(final HttpMethod method) throws FileSystemException,
URIException
{
String pathEncoded = ((URLFileName) getName()).getPathQueryEncoded(urlCharset);
if (!VFS.isUriStyle()
&& (getName().getType() == FileType.FOLDER)
&& !pathEncoded.endsWith("/") )
{ pathEncoded = pathEncoded + "/"; }
method.setPath(pathEncoded);
method.setFollowRedirects(true);
method.setRequestHeader("User-Agent", "Jakarta-Commons-VFS");
}
This seems to work (at least with my unit tests), but it is required that that
the file that is resolved in the first place ends with a trailing slash:
FileObject fo =
VFS.getManager().resolveFile("http://localhost:8080/dav/conf/test/");
I did not provide a patch yet, because I integrated this fix in my own code
which is a fork of VFS 2.0. It is taking too much time to integrate those
patches into VFS trunk and get a new release of the lib. Can't wait until that,
but I will try to port the patch to trunk when I have some time.
> Http/Https listChildren browse support
> --------------------------------------
>
> Key: VFS-199
> URL: https://issues.apache.org/jira/browse/VFS-199
> Project: Commons VFS
> Issue Type: New Feature
> Affects Versions: 1.1
> Reporter: Andrew Franklin
> Attachments: HttpGetList.txt, VFS-199.patch, VFS-199_updated.patch
>
>
> I think this was lodged at some time ago as VFS-79:
> http://www.mail-archive.com/[email protected]/msg83701.html.
> Essentially the ability to browse http via the directory listing structure is
> reasonably important for a number of use cases.
> Mario noted in that previous bug that the parsing of the html isn't
> necessarily trivial but I've submitted a patch that meets my requirements.
> The patch uses java regular expressions which has the requirement of JVM >
> 1.4. Submitting in the hope that other users will find it useful and maybe
> we'll be able to tidy it to the point where it can be integrated into the vfs
> mainline.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira