| Summary: | Error while closing a HttpConnection for a HEAD request | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Stefan Baier <stefan.baier> |
| Component: | WebDAV | Assignee: | Platform-WebDAV-Inbox <platform-webdav-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | Keywords: | helpwanted |
| Version: | 3.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
This component is no longer being actively developed. We encourage users to investigate the capabilities of the Eclipse Web Tools Project. |
I sent an HEAD request for a non existing resource to the WebDAV Servlet implementation delivered with Tomcat 5.0. The response is standard compliant with RFC 2068 (which says: "The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.) and looks like: ------------------------------ 404 /webdav/nonexisting.html content-type: text/html;charset=ISO-8859-1 date: Tue, 05 Oct 2004 08:49:00 GMT content-language: de-DE content-length: 1004 server: Apache-Coyote/1.1 ------------------------------ This means, that although the Content-Length is set to 1004, there is no body sent back to the client. If one closes the corresponding org.eclipse.webdav.http.client.HttpConnection, over which the HEAD request was sent, the follwoing code is executed: ------------------------------ private void endRequest() { ... try { getInputStream().close(); } catch (IOException e) { failed = true; } ... } ------------------------------ In getInputStream() a LimitedInputStream is constructed, which tries to skip the assumedly remaining bytes on the socket. Only in the case, where the HEAD request returns an 200/ok as the status, the LimitedInputStream does not assume any bytes remaining on the socket, as one can see from the following code snippet: ------------------------------ public InputStream getInputStream() throws IOException { ... } else if (method.equals("HEAD") && statusCode == HTTP_OK) { //$NON-NLS-1$ is = new LimitedInputStream(0); } else if ... } ------------------------------ In my opinion this has to be changed to ------------------------------ public InputStream getInputStream() throws IOException { ... } else if (method.equals("HEAD")) { //$NON-NLS-1$ is = new LimitedInputStream(0); } else if ... } ------------------------------ because a HEAD request never sents back a body, as mentioned before.