Bug 50224

Summary: Http11NioProtocol closes connection if headers are sent in different TCP segments
Product: Tomcat 6 Reporter: Nils O. Sel <NOS>
Component: ConnectorsAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P2    
Version: 6.0.29   
Target Milestone: default   
Hardware: PC   
OS: Linux   

Description Nils O. Sel 2010-11-05 13:54:20 UTC
Ive tested an installation that was configured with Http11NioProtocol. When sent a HEAD request, the connection just gets closed. With the default HTTP/1.1 connector the HEAD requests gets a proper response. (I'm doing a HEAD / on a default installation, so it's the default tomcat / page that gets served, not a custom servlet). I have not checked how this behaves with ordinary GET/POST requests.

The part of the default server.xml that I altered:

      <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
               connectionTimeout="20000"
               compression="on"
               compressionMinSize="8912"
               noCompressionUserAgents="gozilla, traviata"
               compressableMimeType="text/html,text/xml,text/plain"
               redirectPort="8443" />


This seems to happen when the request headers get sent in several IP packets. e.g. the HTTP request was:

HEAD / HTTP/1.0\r\n
Host: web01.example.com\r\n
User-Agent: go http package\r\n
\r\n

This request got sent in 4 different packets(tcp segments) - discovered with Wireshark

1. packet: HEAD / HTTP/1.0\r\n
2. packet: Host: web01.myserver.internal\r\n
3. packet: User-Agent: go http package\r\n
4. packet: \r\n

The HTTP/1.1 connector seems to handle the above case fine, responds with 200 OK and a proper response. When the Http11NioProtocol is used, there's no response, the TCP connection just gets closed from the Tomcat side.

This happens specifically when using the go http library(http://golang.org/) run on Fedora 14, below is the simple test case written in go - but I'd guess there's no guarantee the packets always gets sent in different segments (then again maybe the go http library disables the Nagle algorithm)

If anyone want to try to reproduce this using go(http://golang.org/) the simple test was this program:

package main
import (
    "http"
)
func main() {
    resp, err := http.Head("http://web01.myserver.internal/")
    println("after")
    if err != nil {
        print("Error::")
        println(err.String())
    } else {
        println(resp.Status)
    }
}
Comment 1 Mark Thomas 2010-11-05 14:04:35 UTC

*** This bug has been marked as a duplicate of bug 50072 ***