Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363993

Summary: EOFException parsing HEAD response in HttpTester
Product: [RT] Jetty Reporter: Ross A. Baker <baker>
Component: otherAssignee: Jan Bartel <janb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: janb
Version: unspecified   
Target Milestone: 7.5.x   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Ross A. Baker CLA 2011-11-16 22:35:01 EST
Build Identifier: 

Using ServletTester, given the following response to a HEAD request:

----
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 22

----

Calling HttpTester.parse(response) results in an EOFException:

java.io.EOFException
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:309)
        at org.eclipse.jetty.http.HttpParser.parse(HttpParser.java:204)
        at org.eclipse.jetty.testing.HttpTester.parse(HttpTester.java:139)

The HttpTester does not know that this was a response to a HEAD call so it should not expect a body.  This worked through Jetty 7.5.1.  The breaking commit appears to be 12469af49929800e47d13dd71d5c46894f34f17a.  

The HttpParser has a flag for whether to expect a HEAD response, but HttpTester does not know whether it is a HEAD response or not.

Reproducible: Always

Steps to Reproduce:
    public void testParseHeadResponse() throws Exception {
        String response =
            "HTTP/1.1 200 OK\r\n"+
            "Content-Type: text/html\r\n"+
            "Content-Length: 22\r\n"+
            "\r\n";
        new HttpTester().parse(response);
    }
Comment 1 Jan Bartel CLA 2011-11-22 02:17:14 EST
Fixed for jetty-7.6.0.

added HttpTester.parse(String string, boolean isHeadResponse) and
HttpTester.parse(byte[] bytes, boolean isHeadResponse).