[ 
https://issues.apache.org/jira/browse/VFS-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420153#comment-13420153
 ] 

Robert Kornmesser commented on VFS-428:
---------------------------------------

??Are you saying that VFS should add a / to certain requests? Which ones???
Yes and no. For sure requests to directories have to have a trailing slash. But 
of course VFS does not know at request level wich request is a possible 
directory. But Maybe the root request has to be a directory. so that this 
request should end with a /. From the root level on, VFS should know the 
directory structure.

??Are you saying that this is a code bug or a documentation bug???
Imho both! Requests to directories should either end with a trailing slash or 
the httpclient should be configurable to follow redirects. The documentation 
mentioned at http://commons.apache.org/vfs/testserver.html cann not work with 
the current code.

??Should VFS offer an option to follow redirects???
Yes, would be nice. I dont really know the webdav internals, why this denied by 
default.

??Can you post your whole configuration with instructions such that it can be 
reproduced by anyone???
*Webdav-Server*
* Apache HTTPD 2.2.22
* {code:title=/etc/apache2/conf.d/vfstest.conf|borderStyle=solid}
Alias /vfstest /vfstest/

DAVLockDB /var/lib/apache2/dav.lockDB
DAVMinTimeout 600

<Directory /vfstest>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Location />
        DAV On
        Options Indexes MultiViews
        AllowOverride None

        AuthType Basic
        AuthName vfstest_zone
        AuthUserFile /etc/apache2/passwd
        <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                Require user vfsusr
        </Limit>
</Location>
{code}
* htpasswd2 -cmb /etc/apache2/passwd  vfsusr 'vfstest'
* {code:title=ls -R /vfstest/|borderStyle=solid}
/vfstest/:
insgesamt 3204
drwxr-xr-x 4 http http    4096 16. Jul 17:14 .
drwxr-xr-x 3 http http    4096 16. Jul 11:11 ..
-rw-r--r-- 1 http http 3130982 16. Jul 17:14 largefile.tar.gz
-rw-r--r-- 1 http http    1858 16. Jul 17:14 nested.jar
-rw-r--r-- 1 http http   40960 16. Jul 17:14 nested.tar
-rw-r--r-- 1 http http    1317 16. Jul 17:14 nested.tbz2
-rw-r--r-- 1 http http    1159 16. Jul 17:14 nested.tgz
-rw-r--r-- 1 http http    5028 16. Jul 17:14 nested.zip
drwxr-xr-x 3 http http    4096 16. Jul 17:14 read-tests
-rw-r--r-- 1 http http     106 16. Jul 17:14 test-hash-#test.txt
-rw-r--r-- 1 http http    4710 16. Jul 17:14 test.jar
-rw-r--r-- 1 http http     254 16. Jul 17:14 test.mf
-rw-r--r-- 1 http http    3211 16. Jul 17:14 test.policy
-rw-r--r-- 1 http http   30720 16. Jul 17:14 test.tar
-rw-r--r-- 1 http http     918 16. Jul 17:14 test.tbz2
-rw-r--r-- 1 http http    1001 16. Jul 17:14 test.tgz
-rw-r--r-- 1 http http    4880 16. Jul 17:14 test.zip
drwxr-xr-x 2 http http    4096 16. Jul 17:14 write-tests

/vfstest/read-tests:
insgesamt 24
drwxr-xr-x 3 http http 4096 16. Jul 17:14 .
drwxr-xr-x 4 http http 4096 16. Jul 17:14 ..
drwxr-xr-x 5 http http 4096 16. Jul 17:14 dir1
-rw-r--r-- 1 http http    0 16. Jul 17:14 empty.txt
-rw-r--r-- 1 http http   20 16. Jul 17:14 file1.txt
-rw-r--r-- 1 http http   20 16. Jul 17:14 file space.txt
-rw-r--r-- 1 http http   20 16. Jul 17:14 file%.txt

/vfstest/read-tests/dir1:
insgesamt 32
drwxr-xr-x 5 http http 4096 16. Jul 17:14 .
drwxr-xr-x 3 http http 4096 16. Jul 17:14 ..
-rw-r--r-- 1 http http   12 16. Jul 17:14 file1.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file2.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file3.txt
drwxr-xr-x 2 http http 4096 16. Jul 17:14 subdir1
drwxr-xr-x 2 http http 4096 16. Jul 17:14 subdir2
drwxr-xr-x 2 http http 4096 16. Jul 17:14 subdir3

/vfstest/read-tests/dir1/subdir1:
insgesamt 20
drwxr-xr-x 2 http http 4096 16. Jul 17:14 .
drwxr-xr-x 5 http http 4096 16. Jul 17:14 ..
-rw-r--r-- 1 http http   12 16. Jul 17:14 file1.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file2.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file3.txt

/vfstest/read-tests/dir1/subdir2:
insgesamt 20
drwxr-xr-x 2 http http 4096 16. Jul 17:14 .
drwxr-xr-x 5 http http 4096 16. Jul 17:14 ..
-rw-r--r-- 1 http http   12 16. Jul 17:14 file1.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file2.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file3.txt

/vfstest/read-tests/dir1/subdir3:
insgesamt 20
drwxr-xr-x 2 http http 4096 16. Jul 17:14 .
drwxr-xr-x 5 http http 4096 16. Jul 17:14 ..
-rw-r--r-- 1 http http   12 16. Jul 17:14 file1.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file2.txt
-rw-r--r-- 1 http http   12 16. Jul 17:14 file3.txt

/vfstest/write-tests:
insgesamt 12
drwxr-xr-x 2 http http 4096 16. Jul 17:14 .
drwxr-xr-x 4 http http 4096 16. Jul 17:14 ..
-rw-r--r-- 1 http http   44 16. Jul 17:14 dummy.txt
{code}
* svn co 
http://svn.apache.org/repos/asf/commons/proper/vfs/tags/commons-vfs2-project-2.0/core/
 /tmp/vfs2
* cd /tmp/vfs2
* {code:title=src/test/resources/log4j.properties|borderStyle=solid}

log4j.rootLogger=DEBUG, R
log4j.appender.R=org.apache.log4j.ConsoleAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
og4j.appender.R.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
{code}
* mvn -P webdav clean test 
-Dtest.webdav.uri=webdav://vfsusr:vfstest@localhost/vfstest 
-Dtest=WebdavProviderTestCase
* Result:
{code}

 T E S T S
-------------------------------------------------------
Running org.apache.commons.vfs2.provider.webdav.test.WebdavProviderTestCase
Using "/tmp/vfs2/target/test-classes/test-data/temp" as temporary files store.
Set parameter http.useragent = Jakarta Commons-HttpClient/3.1
Set parameter http.protocol.version = HTTP/1.1
Set parameter http.connection-manager.class = class 
org.apache.commons.httpclient.SimpleHttpConnectionManager
Set parameter http.protocol.cookie-policy = default
Set parameter http.protocol.element-charset = US-ASCII
Set parameter http.protocol.content-charset = ISO-8859-1
Set parameter http.method.retry-handler = 
org.apache.commons.httpclient.DefaultHttpMethodRetryHandler@1c8a1c9d
Set parameter http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, 
dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, 
EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy 
HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE 
dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, 
EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z]
Java version: 1.7.0_05
Java vendor: Oracle Corporation
Java class path: 
/tmp/vfs2/target/test-classes:/tmp/vfs2/target/classes:/home/setti/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/home/setti/.m2/repository/ant/ant/1.6.2/ant-1.6.2.jar:/home/setti/.m2/repository/commons-net/commons-net/2.2/commons-net-2.2.jar:/home/setti/.m2/repository/org/apache/commons/commons-compress/1.1/commons-compress-1.1.jar:/home/setti/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar:/home/setti/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar:/home/setti/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar:/home/setti/.m2/repository/org/apache/jackrabbit/jackrabbit-webdav/1.5.2/jackrabbit-webdav-1.5.2.jar:/home/setti/.m2/repository/org/apache/jackrabbit/jackrabbit-jcr-commons/1.5.2/jackrabbit-jcr-commons-1.5.2.jar:/home/setti/.m2/repository/com/jcraft/jsch/0.1.42/jsch-0.1.42.jar:/home/setti/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar:/home/setti/.m2/repository/org/slf4j/slf4j-api/1.5.6/slf4j-api-1.5.6.jar:/home/setti/.m2/repository/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar:/home/setti/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar:/home/setti/.m2/repository/org/apache/maven/scm/maven-scm-api/1.4/maven-scm-api-1.4.jar:/home/setti/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar:/home/setti/.m2/repository/org/apache/maven/scm/maven-scm-provider-svnexe/1.4/maven-scm-provider-svnexe-1.4.jar:/home/setti/.m2/repository/org/apache/maven/scm/maven-scm-provider-svn-commons/1.4/maven-scm-provider-svn-commons-1.4.jar:/home/setti/.m2/repository/regexp/regexp/1.3/regexp-1.3.jar:
Operating system name: Linux
Operating system architecture: amd64
Operating system version: 3.4.5-1-ARCH
SUN 1.7: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; 
SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX 
CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; 
JavaLoginConfig Configuration)
SunRsaSign 1.7: Sun RSA signature provider
SunEC 1.7: Sun Elliptic Curve provider (EC, ECDSA, ECDH)
SunJSSE 1.7: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, 
TLSv1)
SunJCE 1.7: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, 
ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
SunJGSS 1.7: Sun (Kerberos v5, SPNEGO)
SunSASL 1.7: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, 
GSSAPI, EXTERNAL, PLAIN, CRAM-MD5, NTLM; server mechanisms for: DIGEST-MD5, 
GSSAPI, CRAM-MD5, NTLM)
XMLDSig 1.0: XMLDSig (DOM XMLSignatureFactory; DOM KeyInfoFactory)
SunPCSC 1.7: Sun PC/SC provider
Set parameter http.connection-manager.max-per-host = 
{HostConfiguration[host=http://localhost]=5}
Set parameter http.connection-manager.max-total = 50
HttpConnectionManager.getConnection:  config = 
HostConfiguration[host=http://localhost], timeout = 0
Allocating new connection, hostConfig=HostConfiguration[host=http://localhost]
Open connection to localhost:80
>> "HEAD / HTTP/1.1[\r][\n]"
Adding Host request header
>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
>> "Host: localhost[\r][\n]"
>> "[\r][\n]"
<< "HTTP/1.1 200 OK[\r][\n]"
<< "HTTP/1.1 200 OK[\r][\n]"
<< "Date: Sun, 22 Jul 2012 12:45:12 GMT[\r][\n]"
<< "Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1c DAV/2 
PHP/5.4.5[\r][\n]"
<< "Content-Type: text/html;charset=ISO-8859-1[\r][\n]"
<< "[\r][\n]"
Resorting to protocol version default close connection policy
Should NOT close connection, using HTTP/1.1
Releasing connection back to connection manager.
Freeing connection, hostConfig=HostConfiguration[host=http://localhost]
Adding connection at: 1342961112824
Notifying no-one, there are no waiting threads
putFile: webdav://vfsusr:vfstest@localhost/vfstest
putFile: webdav://vfsusr:vfstest@localhost/vfstest/read-tests
putFile: webdav://vfsusr:vfstest@localhost/vfstest/write-tests
HttpConnectionManager.getConnection:  config = 
HostConfiguration[host=http://localhost], timeout = 0
Getting free connection, hostConfig=HostConfiguration[host=http://localhost]
>> "PROPFIND /vfstest/read-tests HTTP/1.1[\r][\n]"
Adding Host request header
>> "Depth: 0[\r][\n]"
>> "User-Agent: Jakarta-Commons-VFS[\r][\n]"
>> "Cache-control: no-cache[\r][\n]"
>> "Cache-store: no-store[\r][\n]"
>> "Pragma: no-cache[\r][\n]"
>> "Expires: 0[\r][\n]"
>> "Host: localhost[\r][\n]"
>> "Content-Length: 112[\r][\n]"
>> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
>> "[\r][\n]"
>> "<?xml version="1.0" encoding="UTF-8"?><D:propfind 
>> xmlns:D="DAV:"><D:prop><D:resourcetype/></D:prop></D:propfind>"
Request body sent
<< "HTTP/1.1 401 Authorization Required[\r][\n]"
<< "HTTP/1.1 401 Authorization Required[\r][\n]"
<< "Date: Sun, 22 Jul 2012 12:45:12 GMT[\r][\n]"
<< "Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1c DAV/2 
PHP/5.4.5[\r][\n]"
<< "WWW-Authenticate: Basic realm="vfstest_zone"[\r][\n]"
<< "Vary: accept-language,accept-charset[\r][\n]"
<< "Accept-Ranges: bytes[\r][\n]"
<< "Content-Length: 589[\r][\n]"
<< "Content-Type: text/html; charset=iso-8859-1[\r][\n]"
<< "Content-Language: en[\r][\n]"
<< "[\r][\n]"
Authorization required
Supported authentication schemes in the order of preference: [ntlm, digest, 
basic]
Challenge for ntlm authentication scheme not available
Challenge for digest authentication scheme not available
basic authentication scheme selected
Using authentication scheme: basic
Authorization challenge processed
Authentication scope: BASIC 'vfstest_zone'@localhost:80
Retry authentication
<< "<!--#set var="TITLE" value="Authentication required!"[\n]"
<< "--><!--#include virtual="include/top.html" -->[\n]"
<< "[\n]"
<< "    This server could not verify that you are authorized to access[\n]"
<< "    the URL "<!--#echo encoding="url" var="REDIRECT_URL" -->".[\n]"
<< "    You either supplied the wrong credentials (e.g., bad password), or 
your[\n]"
<< "    browser doesn't understand how to supply the credentials required.[\n]"
<< "[\n]"
<< "  <!--#include virtual="include/spacer.html" -->[\n]"
<< "[\n]"
<< "    In case you are allowed to request the document, please[\n]"
<< "    check your user-id and password and try again.[\n]"
<< "[\n]"
<< "<!--#include virtual="include/bottom.html" -->[\n]"
Resorting to protocol version default close connection policy
Should NOT close connection, using HTTP/1.1
Authenticating with BASIC 'vfstest_zone'@localhost:80
Credential charset not configured, using HTTP element charset
>> "PROPFIND /vfstest/read-tests HTTP/1.1[\r][\n]"
Adding Host request header
>> "Depth: 0[\r][\n]"
>> "User-Agent: Jakarta-Commons-VFS[\r][\n]"
>> "Cache-control: no-cache[\r][\n]"
>> "Cache-store: no-store[\r][\n]"
>> "Pragma: no-cache[\r][\n]"
>> "Expires: 0[\r][\n]"
>> "Content-Length: 112[\r][\n]"
>> "Content-Type: text/xml; charset=UTF-8[\r][\n]"
>> "Authorization: Basic dmZzdXNyOnZmc3Rlc3Q=[\r][\n]"
>> "Host: localhost[\r][\n]"
>> "[\r][\n]"
>> "<?xml version="1.0" encoding="UTF-8"?><D:propfind 
>> xmlns:D="DAV:"><D:prop><D:resourcetype/></D:prop></D:propfind>"
Request body sent
<< "HTTP/1.1 301 Moved Permanently[\r][\n]"
<< "HTTP/1.1 301 Moved Permanently[\r][\n]"
<< "Date: Sun, 22 Jul 2012 12:45:12 GMT[\r][\n]"
<< "Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1c DAV/2 
PHP/5.4.5[\r][\n]"
<< "Location: http://localhost/vfstest/read-tests/[\r][\n]";
<< "Content-Length: 363[\r][\n]"
<< "Content-Type: text/html; charset=iso-8859-1[\r][\n]"
<< "[\r][\n]"
Redirect required
<< "<"
<< "!"
<< "D"
<< "O"
<< "CTYPE HTML PUBLIC "-//IETF//"
<< "DTD HTML 2.0//EN">[\n]"
<< "<html><head>[\n]"
<< "<title>301 Moved Permanently</title>[\n]"
<< "</head><body>[\n]"
<< "<h1>Moved Permanently</h1>[\n]"
<< "<p>The document has moved <a 
href="http://localhost/vfstest/read-tests/";>here</a>.</p>[\n]"
<< "<hr>[\n]"
<< "<address>Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.1c DAV/2 PHP/5.4.5 
Server at localhost Port 80</address>[\n]"
<< "</body></html>[\n]"
Resorting to protocol version default close connection policy
Should NOT close connection, using HTTP/1.1
Releasing connection back to connection manager.
Freeing connection, hostConfig=HostConfiguration[host=http://localhost]
Adding connection at: 1342961112947
Notifying no-one, there are no waiting threads
DavException: (301) Moved Permanently
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.449 sec <<< 
FAILURE!

Results :

Tests in error: 
  
junit.framework.TestSuite@3a2128d0(org.apache.commons.vfs2.provider.webdav.test.WebdavProviderTestSuite):
 Could not determine the type of file 
"webdav://vfsusr:***@localhost/vfstest/read-tests".

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
{code}
                
> DavException: (301) Moved Permanently 
> --------------------------------------
>
>                 Key: VFS-428
>                 URL: https://issues.apache.org/jira/browse/VFS-428
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0, 2.1
>         Environment: Apache 2.2.22 as Testerver and setted up like 
> http://commons.apache.org/vfs/testserver.html (but changed the 'crypt' 
> password)
>            Reporter: Robert Kornmesser
>            Priority: Blocker
>              Labels: webdav
>
> Running the WebdavProviderTestCase using mvn -P webdav clean test 
> -Dtest.webdav.uri=webdav://vfsusr:vfstest@localhost/vfstest 
> -Dtest=WebdavProviderTestCase results in 
> {code}DavException: (301) Moved Permanently
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.645 sec <<< 
> FAILURE!
> Results :
> Tests in error: 
>   
> junit.framework.TestSuite@55c9be00(org.apache.commons.vfs2.provider.webdav.test.WebdavProviderTestCase$1):
>  Could not determine the type of file 
> "webdav://vfsusr:****@localhost/vfstest/read-tests".
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
> {code}
> The deeper Problem is, that the HttpClient using by VFS does not append a 
> trailing slash and mod_dir of httpd has "DirectorySlash On" per default. So 
> httpd send 301 redirect to the same url with / appended.
> I know that for this reason of problematic webdav client apache introduced 
> "redirect-carefully" for some user agents using the "BrowserMatch" directive. 
> So I just tried adding the following into my <Directory> directive
> {code}
> BrowserMatch "^Jakarta-Commons-VFS" redirect-carefully
> BrowserMatch "^Jakarta Commons-HttpClient/3.0" redirect-carefully
> BrowserMatch "^Jakarta Commons-HttpClient/3.1" redirect-carefully
> {code}
> Its needed to have Jakarta-Commons-VFS *and* Jakarta Commons-HttpClient 
> because of two requests from commons vfs using two different user agents.
> But instead of solving the issue, I get for every FileObject.getChildren() 
> call at least one FileObject of type imaginary with the same basename as the 
> parent. Thats not a problem at all (besides that this is totally wrong!) but 
> deleting a parent just dont work anymore, because of an *non-existent* 
> imaginary file inside the dir which cannot be deleted of course.
> To cut a long story short, what is the right httpd webdav server config to 
> use 2.0 Release version of VFS?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to