diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java index bcaa539d248f..955b7c7d4338 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java @@ -238,26 +238,35 @@ public static class ConnectRequest extends Request { private final String _protocol; - public ConnectRequest(HttpScheme scheme, HostPortHttpField authority, String path, HttpFields headers, String protocol) + public ConnectRequest(HttpScheme scheme, HostPortHttpField authority, String pathQuery, HttpFields headers, String protocol) { - this(NanoTime.now(), scheme == null ? null : scheme.asString(), authority, path, headers, protocol); + this(scheme == null ? null : scheme.asString(), authority, pathQuery, headers, protocol); } - public ConnectRequest(long beginNanoTime, HttpScheme scheme, HostPortHttpField authority, String path, HttpFields headers, String protocol) + public ConnectRequest(long beginNanoTime, HttpScheme scheme, HostPortHttpField authority, String pathQuery, HttpFields headers, String protocol) { - this(beginNanoTime, scheme == null ? null : scheme.asString(), authority, path, headers, protocol); + this(beginNanoTime, scheme == null ? null : scheme.asString(), authority, pathQuery, headers, protocol); } - public ConnectRequest(String scheme, HostPortHttpField authority, String path, HttpFields headers, String protocol) + public ConnectRequest(String scheme, HostPortHttpField authority, String pathQuery, HttpFields headers, String protocol) { - this(NanoTime.now(), scheme, authority, path, headers, protocol); + this(NanoTime.now(), scheme, authority, pathQuery, headers, protocol); } - public ConnectRequest(long beginNanoTime, String scheme, HostPortHttpField authority, String path, HttpFields headers, String protocol) + public ConnectRequest(long beginNanoTime, String scheme, HostPortHttpField authority, String pathQuery, HttpFields headers, String protocol) { - super(beginNanoTime, HttpMethod.CONNECT.asString(), - HttpURI.build().scheme(scheme).host(authority == null ? null : authority.getHost()).port(authority == null ? -1 : authority.getPort()).pathQuery(path), - HttpVersion.HTTP_2, headers, -1, null); + super(beginNanoTime, + HttpMethod.CONNECT.asString(), + HttpURI.build() + .scheme(scheme) + .host(authority == null ? null : authority.getHost()) + .port(authority == null ? -1 : authority.getPort()) + .pathQuery(pathQuery), + HttpVersion.HTTP_2, + headers, + -1, + null + ); _protocol = protocol; } diff --git a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java index 4097b75204cb..cf3fe456838f 100644 --- a/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java +++ b/jetty-core/jetty-http2/jetty-http2-client-transport/src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpSenderOverHTTP2.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Promise; +import org.eclipse.jetty.util.URIUtil; public class HttpSenderOverHTTP2 extends HttpSender { @@ -64,7 +65,8 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool else { HostPortHttpField authority = new HostPortHttpField(request.getHost(), request.getPort()); - metaData = new MetaData.ConnectRequest(request.getScheme(), authority, request.getPath(), request.getHeaders(), upgradeProtocol); + String pathQuery = URIUtil.addPathQuery(request.getPath(), request.getQuery()); + metaData = new MetaData.ConnectRequest(request.getScheme(), authority, pathQuery, request.getHeaders(), upgradeProtocol); } } else diff --git a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java index 4774468b6a11..b66afee48236 100644 --- a/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-client-transport/src/main/java/org/eclipse/jetty/http3/client/transport/internal/HttpSenderOverHTTP3.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.http3.frames.HeadersFrame; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.util.URIUtil; public class HttpSenderOverHTTP3 extends HttpSender { @@ -64,7 +65,8 @@ protected void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, bool else { HostPortHttpField authority = new HostPortHttpField(request.getHost(), request.getPort()); - metaData = new MetaData.ConnectRequest(request.getScheme(), authority, request.getPath(), request.getHeaders(), upgradeProtocol); + String pathQuery = URIUtil.addPathQuery(request.getPath(), request.getQuery()); + metaData = new MetaData.ConnectRequest(request.getScheme(), authority, pathQuery, request.getHeaders(), upgradeProtocol); } } else diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java index ffab4054f09e..46e93aa6deaa 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/WebSocketOverHTTP2Test.java @@ -179,7 +179,7 @@ private void testWebSocketOverDynamicTransport(Function new EchoSocket()); + factory.addMapping("/ws/echo/query", (request, response) -> + { + assertNotNull(request.getQueryString()); + return new EchoSocket(); + }); factory.addMapping("/ws/null", (request, response) -> { response.sendError(HttpStatus.SERVICE_UNAVAILABLE_503, "null"); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java index 9847fdedf746..5847c7149d63 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/WebSocketOverHTTP2Test.java @@ -162,7 +162,7 @@ private void testWebSocketOverDynamicTransport(Function new EchoSocket()); + factory.addMapping("/ws/echo/query", (request, response) -> + { + assertNotNull(request.getQueryString()); + return new EchoSocket(); + }); factory.addMapping("/ws/null", (request, response) -> { response.sendError(HttpStatus.SERVICE_UNAVAILABLE_503, "null");