hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pill, Juergen" <Juergen.P...@softwareag.com>
Subject Bug in Head Method (with authenticated server)
Date Mon, 16 Dec 2002 10:25:20 GMT
Hello,

I think I found a problem with the head method, if the server runs in
authentication mode. Executing following piece of code results in an
exception:


        {  // this code is run-able as it is, just compile it
        HttpClient client = new HttpClient();
        HttpState state = new WebdavState();
        Credentials cred = new UsernamePasswordCredentials("guest",
"guest");
        client.startSession("tamino.demozone.softwareag.com", 80);
        state.setCredentials(null, cred);
        client.setState(state);
        HeadMethod method = new
HeadMethod("/taminowebdavserver/yourstore/PictureDemo");
            try {
                client.executeMethod(method);
                client.endSession();
            } catch (java.io.IOException e) {
                e.printStackTrace();
            }
        }




Dec 16, 2002 11:09:07 AM org.apache.commons.httpclient.HttpMethodBase
processRequest
WARNING: Recoverable exception caught when reading response
org.apache.commons.httpclient.HttpRecoverableException: Error in parsing the
status  line from the response: unable to find line starting with "HTTP/"
	at
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.j
ava:1848)
	at
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.jav
a:1606)
	at
org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.j
ava:2264)
	at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:862
)
	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:574)
	at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:493)
	at
org.apache.slide.testsuite.testtools.tprocessor.TProcessors.main(TProcessors
.java:254)






The reason is (IMO) that this coding results in 2 http calls. The first head
call returns 401, the command and header line are consumed, but NOT the
body. The second call is issued, the head command is executed with success
at the server, but now the method readStatusLine is confused reading the
body of the First head call.


If I code the headMethod. ReadResponseBody  like following, the result
behaves as expected, but a println is created:


    protected void readResponseBody(HttpState state, HttpConnection conn)
    throws IOException, HttpException {
        log.trace(
            "enter HeadMethod.readResponseBody(HttpState, HttpConnection)");

        // despite the possible presence of a content-length header,
        // HEAD returns no response body in case of response code 200
        if (this.getStatusLine().getStatusCode() == 200) {
            responseBodyConsumed();
        } else {
            super.readResponseBody(state, conn);
        }
    }



INFO: Recoverable exception caught when writing request


Best regards,

Juergen Pill





Sniffer Protocol (without patch):


11:08:50.743
From: Remote client, To: PWB's internal socket server
57 bytes of data has been received from the remote client.
HEAD /taminowebdavserver/yourstore/PictureDemo HTTP/1.1

11:08:50.743
From: PWB's internal socket client, To: Remote server
57 bytes of data has been buffered. (Previous action still in progress)
HEAD /taminowebdavserver/yourstore/PictureDemo HTTP/1.1

11:08:50.934
From: Remote client, To: PWB's internal socket server
16 bytes of data has been received from the remote client.
Host: pcjpl:81

11:08:50.944
From: Remote client, To: PWB's internal socket server
46 bytes of data has been received from the remote client.
User-Agent: Jakarta Commons-HttpClient/2.0M1

11:08:50.954
From: Remote client, To: PWB's internal socket server
2 bytes of data has been received from the remote client.


11:08:51.104
From: Remote server, To: PWB's internal socket client
925 bytes of data has been received from the remote server.
HTTP/1.1 401 
Date: Mon, 16 Dec 2002 10:08:55 GMT
Server: Apache/1.3.27 (Win32) mod_jk/1.2.0
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
WWW-Authenticate: Basic realm="Tamino WebDAV Server"
Content-Type: text/html

<html><head><title>Apache Tomcat/4.1.9 - Error
report</title><STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color :
white;background-color : #0086b2;} H3{font-family :
sans-serif,Arial,Tahoma;color : white;background-color : #0086b2;}
BODY{font-family : sans-serif,Arial,Tahoma;color : black;background-color :
white;} B{color : white;background-color : #0086b2;} HR{color : #0086b2;}
--></STYLE> </head><body><h1>HTTP Status 401 - </h1><HR
size="1"
noshade><p><b>type</b> Status report</p><p><b>message</b>
<u></u></p><p><b>description</b> <u>This request
requires HTTP
authentication ().</u></p><HR size="1" noshade><h3>Apache
Tomcat/4.1.9</h3></body></html>
11:08:51.154
From: Remote client, To: PWB's internal socket server
57 bytes of data has been received from the remote client.
HEAD /taminowebdavserver/yourstore/PictureDemo HTTP/1.1

11:08:51.164
From: Remote client, To: PWB's internal socket server
39 bytes of data has been received from the remote client.
Authorization: Basic Z3Vlc3Q6Z3Vlc3Q=

11:08:51.174
From: Remote client, To: PWB's internal socket server
16 bytes of data has been received from the remote client.
Host: pcjpl:81

11:08:51.174
From: Remote client, To: PWB's internal socket server
46 bytes of data has been received from the remote client.
User-Agent: Jakarta Commons-HttpClient/2.0M1

11:08:51.184
From: Remote client, To: PWB's internal socket server
2 bytes of data has been received from the remote client.


11:08:52.927
From: Remote server, To: PWB's internal socket client
370 bytes of data has been received from the remote server.
HTTP/1.1 200 
Date: Mon, 16 Dec 2002 10:08:55 GMT
Server: Apache/1.3.27 (Win32) mod_jk/1.2.0
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=BC6AFBDC3A428547E3EB91A89ADDE9F3;
Path=/taminowebdavserver
ETag: "0-1037896403000"
Last-Modified: Thu, 21 Nov 2002 16:33:23 GMT
Content-Length: 0
Content-Type: 




Mime
View raw message