Merge github.com:eclipse/jetty.project into jetty-11.0.x
This commit is contained in:
commit
e46f0a62b2
|
@ -1283,7 +1283,9 @@ public class Request implements HttpServletRequest
|
|||
{
|
||||
final StringBuffer url = new StringBuffer(128);
|
||||
URIUtil.appendSchemeHostPort(url, getScheme(), getServerName(), getServerPort());
|
||||
url.append(getRequestURI());
|
||||
String path = getRequestURI();
|
||||
if (path != null)
|
||||
url.append(path);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ import org.eclipse.jetty.http.HttpCookie;
|
|||
import org.eclipse.jetty.http.HttpField;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
|
@ -856,6 +857,52 @@ public class RequestTest
|
|||
assertEquals(" x=z; ", results.get(i));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectRequestURLSameAsHost() throws Exception
|
||||
{
|
||||
final AtomicReference<String> resultRequestURL = new AtomicReference<>();
|
||||
final AtomicReference<String> resultRequestURI = new AtomicReference<>();
|
||||
_handler._checker = (request, response) ->
|
||||
{
|
||||
resultRequestURL.set(request.getRequestURL().toString());
|
||||
resultRequestURI.set(request.getRequestURI());
|
||||
return true;
|
||||
};
|
||||
|
||||
String rawResponse = _connector.getResponse(
|
||||
"CONNECT myhost:9999 HTTP/1.1\n" +
|
||||
"Host: myhost:9999\n" +
|
||||
"Connection: close\n" +
|
||||
"\n");
|
||||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.getStatus(), is(HttpStatus.OK_200));
|
||||
assertThat("request.getRequestURL", resultRequestURL.get(), is("http://myhost:9999/"));
|
||||
assertThat("request.getRequestURI", resultRequestURI.get(), is("/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectRequestURLDifferentThanHost() throws Exception
|
||||
{
|
||||
final AtomicReference<String> resultRequestURL = new AtomicReference<>();
|
||||
final AtomicReference<String> resultRequestURI = new AtomicReference<>();
|
||||
_handler._checker = (request, response) ->
|
||||
{
|
||||
resultRequestURL.set(request.getRequestURL().toString());
|
||||
resultRequestURI.set(request.getRequestURI());
|
||||
return true;
|
||||
};
|
||||
|
||||
String rawResponse = _connector.getResponse(
|
||||
"CONNECT myhost:9999 HTTP/1.1\n" +
|
||||
"Host: otherhost:8888\n" + // per spec, this is ignored if request-target is authority-form
|
||||
"Connection: close\n" +
|
||||
"\n");
|
||||
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
|
||||
assertThat(response.getStatus(), is(HttpStatus.OK_200));
|
||||
assertThat("request.getRequestURL", resultRequestURL.get(), is("http://myhost:9999/"));
|
||||
assertThat("request.getRequestURI", resultRequestURI.get(), is("/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHostPort() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue