You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2013/05/09 22:27:01 UTC

[Bug 54947] New: Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

            Bug ID: 54947
           Summary: Http11NioProtocol generates HTTP 505 responses on
                    valid requests if request is split across multiple
                    packets
           Product: Tomcat 6
           Version: 6.0.36
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: greg.2.harris@nokia.com
    Classification: Unclassified

If an HTTP request is broken up across multiple packets *and* the first packet
contains a GET request up to "\r" AND the "\n" terminating the first line of
the request is included in the next packet Tomcat incorrectly throws an HTTP
"505 Version Not Supported" response.  This is with the Http11NioProtocol
connector only - the default HTTP/1.1 connector does not exhibit this problem.

An example request:
Packet 1: GET / HTTP/1.1\r
Packet 2: \nHost: localhost\r\n
Packet 3: Connection: Close\r\n\r\n

Response:
HTTP/1.1 505 HTTP Version Not Supported
Server: Apache-Coyote/1.1
Date: Thu, 09 May 2013 20:23:58 GMT
Connection: close

The following Python program reproduces the problem for me in both Tomcat
6.0.37 and Tomcat 7.0.39:
"""
#!/usr/bin/python

import socket
import time

s = socket.socket()
s.connect(("localhost",8080))
s.sendall("GET / HTTP/1.1\r")
time.sleep(1.5) # make sure the above goes out in its own packet
s.sendall("\nHost: localhost\r\n")
s.sendall("Connection: close\r\n\r\n")
print s.makefile().read()
"""

Moving the "\n" to from the second sendall to the end of the first sendall
causes Tomcat to respond correctly.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

Konstantin Preißer <pr...@web.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Connectors                  |Connectors
            Version|6.0.36                      |7.0.40
            Product|Tomcat 6                    |Tomcat 7
   Target Milestone|default                     |---

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

--- Comment #3 from Konstantin Preißer <pr...@web.de> ---
Ok, sorry for changing the version.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Mark Thomas <ma...@apache.org> ---
Fixed in 6.0.x and will be included in 6.0.38 onwards.

Thanks again for the patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Connectors                  |Connectors
            Version|7.0.40                      |6.0.36
            Product|Tomcat 7                    |Tomcat 6
   Target Milestone|---                         |default

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Restore originally reported version.

By default, bugs get fixed in trunk and back-ported until the reported version
is reached so this needs to be left as the original value else 6.0.x might not
get fixed.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Thanks for the report, test case and fix.

I added a test to Tomcat's unit tests based on the provided test case that
confirmed that problem. I also confirmed the proposed patch fixes the issue.

The patch has been applied to trunk and 7.0.x and will be included in 7.0.41
onwards.

The patch has been proposed for 6.0.x

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 54947] Http11NioProtocol generates HTTP 505 responses on valid requests if request is split across multiple packets

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54947

--- Comment #1 from Konstantin Preißer <pr...@web.de> ---
Created attachment 30272
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30272&action=edit
Patch for trunk

Hi,

I can reproduce the issue with current trunk and Tomcat 7.0.40.

Attached is a patch against trunk that fixes the issue for me by resolving a
logic error in InternalNioInputBuffer ("end = 0" was set twice: when starting
to read the HTTP version up to \r, and after the \n has been received; which
meant "end" was set to the position of "\n" instead of "\r", causing the
version string to be "HTTP/1.1\r" instead of "HTTP/1.1").

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org