438204 leave IPv6 addresses [] wrapped in getServerName
This commit is contained in:
parent
50f11bea09
commit
5f033b48d5
|
@ -860,7 +860,7 @@ public class HttpParser
|
|||
{
|
||||
throw new BadMessage(HttpStatus.BAD_REQUEST_400,"Bad IPv6 Host header");
|
||||
}
|
||||
host = host.substring(1,len-1);
|
||||
host = host.substring(0,len);
|
||||
}
|
||||
else if (len!=host.length())
|
||||
host = host.substring(0,len);
|
||||
|
|
|
@ -539,8 +539,6 @@ public class HttpURI
|
|||
{
|
||||
if (_host==_port)
|
||||
return null;
|
||||
if (_raw[_host]=='[')
|
||||
return new String(_raw,_host+1,_port-_host-2,_charset);
|
||||
return new String(_raw,_host,_port-_host,_charset);
|
||||
}
|
||||
|
||||
|
|
|
@ -1294,7 +1294,7 @@ public class HttpParserTest
|
|||
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler);
|
||||
parser.parseNext(buffer);
|
||||
assertEquals("::1",_host);
|
||||
assertEquals("[::1]",_host);
|
||||
assertEquals(0,_port);
|
||||
}
|
||||
|
||||
|
@ -1372,7 +1372,7 @@ public class HttpParserTest
|
|||
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
|
||||
HttpParser parser= new HttpParser(handler);
|
||||
parser.parseNext(buffer);
|
||||
assertEquals("::1",_host);
|
||||
assertEquals("[::1]",_host);
|
||||
assertEquals(8888,_port);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ public class HttpURITest
|
|||
{
|
||||
{"/path/to/context",null,null,"-1","/path/to/context",null,null,null},
|
||||
{"http://example.com/path/to/context;param?query=%22value%22#fragment","http","example.com","-1","/path/to/context","param","query=%22value%22","fragment"},
|
||||
{"http://[::1]/path/to/context;param?query=%22value%22#fragment","http","::1","-1","/path/to/context","param","query=%22value%22","fragment"},
|
||||
{"http://[::1]/path/to/context;param?query=%22value%22#fragment","http","[::1]","-1","/path/to/context","param","query=%22value%22","fragment"},
|
||||
{"http://example.com:8080/path/to/context;param?query=%22value%22#fragment","http","example.com","8080","/path/to/context","param","query=%22value%22","fragment"},
|
||||
{"http://[::1]:8080/path/to/context;param?query=%22value%22#fragment","http","::1","8080","/path/to/context","param","query=%22value%22","fragment"},
|
||||
{"http://[::1]:8080/path/to/context;param?query=%22value%22#fragment","http","[::1]","8080","/path/to/context","param","query=%22value%22","fragment"},
|
||||
};
|
||||
|
||||
public static int
|
||||
|
|
|
@ -1247,7 +1247,7 @@ public class Request implements HttpServletRequest
|
|||
_port=0;
|
||||
return _serverName;
|
||||
}
|
||||
_serverName = hostPort.substring(1,len-1);
|
||||
_serverName = hostPort.substring(0,len);
|
||||
}
|
||||
else if (len==hostPort.length())
|
||||
_serverName=hostPort;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CheckReverseProxyHeadersTest
|
|||
@Override
|
||||
public void validate(HttpServletRequest request)
|
||||
{
|
||||
assertEquals("::1", request.getServerName());
|
||||
assertEquals("[::1]", request.getServerName());
|
||||
assertEquals(80, request.getServerPort());
|
||||
assertEquals("10.20.30.40", request.getRemoteAddr());
|
||||
assertEquals("10.20.30.40", request.getRemoteHost());
|
||||
|
@ -84,7 +84,7 @@ public class CheckReverseProxyHeadersTest
|
|||
@Override
|
||||
public void validate(HttpServletRequest request)
|
||||
{
|
||||
assertEquals("::1", request.getServerName());
|
||||
assertEquals("[::1]", request.getServerName());
|
||||
assertEquals(8888, request.getServerPort());
|
||||
assertEquals("10.20.30.40", request.getRemoteAddr());
|
||||
assertEquals("10.20.30.40", request.getRemoteHost());
|
||||
|
|
|
@ -136,11 +136,11 @@ public class HttpURITest
|
|||
/*33*/ {"/?abc=test",null, null, null,null,"/", null,"abc=test",null},
|
||||
/*34*/ {"/#fragment",null, null, null,null,"/", null,null,"fragment"},
|
||||
/*35*/ {"http://192.0.0.1:8080/","http","//192.0.0.1:8080","192.0.0.1","8080","/",null,null,null},
|
||||
/*36*/ {"http://[2001:db8::1]:8080/","http","//[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
|
||||
/*37*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
|
||||
/*38*/ {"http://[2001:db8::1]/","http","//[2001:db8::1]","2001:db8::1",null,"/",null,null,null},
|
||||
/*36*/ {"http://[2001:db8::1]:8080/","http","//[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
|
||||
/*37*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
|
||||
/*38*/ {"http://[2001:db8::1]/","http","//[2001:db8::1]","[2001:db8::1]",null,"/",null,null,null},
|
||||
/*39*/ {"//[2001:db8::1]:8080/",null,null,null,null,"//[2001:db8::1]:8080/",null,null,null},
|
||||
/*40*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","2001:db8::1","8080","/",null,null,null},
|
||||
/*40*/ {"http://user@[2001:db8::1]:8080/","http","//user@[2001:db8::1]:8080","[2001:db8::1]","8080","/",null,null,null},
|
||||
/*41*/ {"*",null,null,null,null,"*",null, null,null}
|
||||
};
|
||||
|
||||
|
@ -353,7 +353,7 @@ public class HttpURITest
|
|||
{
|
||||
/* 0*/ {" localhost:8080 ","localhost","8080"},
|
||||
/* 1*/ {" 127.0.0.1:8080 ","127.0.0.1","8080"},
|
||||
/* 2*/ {" [127::0::0::1]:8080 ","127::0::0::1","8080"},
|
||||
/* 2*/ {" [127::0::0::1]:8080 ","[127::0::0::1]","8080"},
|
||||
/* 3*/ {" error ",null,null},
|
||||
/* 4*/ {" http://localhost:8080/ ",null,null},
|
||||
};
|
||||
|
|
|
@ -485,7 +485,7 @@ public class RequestTest
|
|||
assertThat(response,Matchers.containsString("200 OK"));
|
||||
assertEquals("http://[::1]/",results.get(i++));
|
||||
assertEquals("0.0.0.0",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("80",results.get(i++));
|
||||
|
||||
|
||||
|
@ -499,7 +499,7 @@ public class RequestTest
|
|||
assertThat(response,Matchers.containsString("200 OK"));
|
||||
assertEquals("http://[::1]:8888/",results.get(i++));
|
||||
assertEquals("0.0.0.0",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("8888",results.get(i++));
|
||||
|
||||
|
||||
|
@ -515,7 +515,7 @@ public class RequestTest
|
|||
assertThat(response,Matchers.containsString("200 OK"));
|
||||
assertEquals("https://[::1]/",results.get(i++));
|
||||
assertEquals("remote",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("443",results.get(i++));
|
||||
|
||||
|
||||
|
@ -531,7 +531,7 @@ public class RequestTest
|
|||
assertThat(response,Matchers.containsString("200 OK"));
|
||||
assertEquals("https://[::1]:8888/",results.get(i++));
|
||||
assertEquals("remote",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("8888",results.get(i++));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue