Issue #8578 - Changes from review · jetty/jetty.project@5944ff4 (original) (raw)

`@@ -84,6 +84,7 @@

`

84

84

`import static org.hamcrest.Matchers.containsString;

`

85

85

`import static org.hamcrest.Matchers.is;

`

86

86

`import static org.hamcrest.Matchers.not;

`

``

87

`+

import static org.hamcrest.Matchers.nullValue;

`

87

88

`import static org.hamcrest.Matchers.startsWith;

`

88

89

`import static org.junit.jupiter.api.Assertions.assertEquals;

`

89

90

`import static org.junit.jupiter.api.Assertions.assertFalse;

`

`@@ -874,14 +875,14 @@ public boolean check(HttpServletRequest request, HttpServletResponse response)

`

874

875

` }

`

875

876

``

876

877

`@Test

`

877

``

`-

public void testConnectRequestURL() throws Exception

`

``

878

`+

public void testConnectRequestURLSameAsHost() throws Exception

`

878

879

` {

`

879

880

`final AtomicReference resultRequestURL = new AtomicReference<>();

`

880

881

`final AtomicReference resultRequestURI = new AtomicReference<>();

`

881

882

`_handler._checker = (request, response) ->

`

882

883

` {

`

883

``

`-

resultRequestURL.set("" + request.getRequestURL());

`

884

``

`-

resultRequestURI.set("" + request.getRequestURI());

`

``

884

`+

resultRequestURL.set(request.getRequestURL().toString());

`

``

885

`+

resultRequestURI.set(request.getRequestURI());

`

885

886

`return true;

`

886

887

` };

`

887

888

``

`@@ -892,8 +893,31 @@ public void testConnectRequestURL() throws Exception

`

892

893

`"\n");

`

893

894

`HttpTester.Response response = HttpTester.parseResponse(rawResponse);

`

894

895

`assertThat(response.getStatus(), is(HttpStatus.OK_200));

`

895

``

`-

assertThat(resultRequestURL.get(), is("http://myhost:9999"));

`

896

``

`-

assertThat(resultRequestURI.get(), is("myhost:9999"));

`

``

896

`+

assertThat("request.getRequestURL", resultRequestURL.get(), is("http://myhost:9999"));

`

``

897

`+

assertThat("request.getRequestURI", resultRequestURI.get(), is(nullValue()));

`

``

898

`+

}

`

``

899

+

``

900

`+

@Test

`

``

901

`+

public void testConnectRequestURLDifferentThanHost() throws Exception

`

``

902

`+

{

`

``

903

`+

final AtomicReference resultRequestURL = new AtomicReference<>();

`

``

904

`+

final AtomicReference resultRequestURI = new AtomicReference<>();

`

``

905

`+

_handler._checker = (request, response) ->

`

``

906

`+

{

`

``

907

`+

resultRequestURL.set(request.getRequestURL().toString());

`

``

908

`+

resultRequestURI.set(request.getRequestURI());

`

``

909

`+

return true;

`

``

910

`+

};

`

``

911

+

``

912

`+

String rawResponse = _connector.getResponse(

`

``

913

`+

"CONNECT myhost:9999 HTTP/1.1\n" +

`

``

914

`+

"Host: otherhost:8888\n" + // per spec, this is ignored if request-target is authority-form

`

``

915

`+

"Connection: close\n" +

`

``

916

`+

"\n");

`

``

917

`+

HttpTester.Response response = HttpTester.parseResponse(rawResponse);

`

``

918

`+

assertThat(response.getStatus(), is(HttpStatus.OK_200));

`

``

919

`+

assertThat("request.getRequestURL", resultRequestURL.get(), is("http://myhost:9999"));

`

``

920

`+

assertThat("request.getRequestURI", resultRequestURI.get(), is(nullValue()));

`

897

921

` }

`

898

922

``

899

923

`@Test

`