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

Bug 345900

Summary: Splitting of host:port fails on IPv6 based host field in HTTP request
Product: [RT] Jetty Reporter: Joakim Eriksson <joakime>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox, mgorovoy
Version: unspecified   
Target Milestone: 7.2.x   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Joakim Eriksson CLA 2011-05-16 05:39:31 EDT
Build Identifier: 7.4.1.v2011-05-13

In the Request.java code the parsing of host:port fails when an IPv6 address is used in the http host field.

I have added a suggestion in the below code-snippet that will avoid interpreting one of the colons in an IPv6 address as a port colon.

---
            for (int i=hostPort.length();i-->0;)   
            {
		/* support for IPv6 address without ports */
                if (hostPort.peek(hostPort.getIndex()+i)==']') {
		    break;
		}
                if (hostPort.peek(hostPort.getIndex()+i)==':')
                {
                    _serverName=BufferUtil.to8859_1_String(hostPort.peek(hostPort.getIndex(), i));
                    _port=BufferUtil.toInt(hostPort.peek(hostPort.getIndex()+i+1, hostPort.length()-i-1));
                    return _serverName;
                }
            }
----




Reproducible: Always

Steps to Reproduce:
1. start up jetty with jetty -jar start.jar jetty.port=80
2. browse to a IPv6 based address (that you happen to have on one of your interfaces - I used aaaa::1 on a microsoft loopback adapter)
3. browse to http:://[aaaa::1]/anything.html
Comment 1 Greg Wilkins CLA 2011-05-16 23:41:01 EDT
hmmm it is working for me for http://[::1]:8080/dump/info

I'll work out how/why
Comment 2 Michael Gorovoy CLA 2011-05-16 23:43:21 EDT
(In reply to comment #1)
> hmmm it is working for me for http://[::1]:8080/dump/info

Greg, I think the problem occurs with http://[::1]/dump/info...
Comment 3 Greg Wilkins CLA 2011-05-17 00:19:29 EDT
Ah yes - fixed in r3160