Skip to content

Commit

Permalink
Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Jan 8, 2024
2 parents 356f400 + 5d7dc71 commit 581f9ae
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void testWebSocketOverDynamicTransport(Function<ClientConnector, ClientC
startClient(protocolFn);

EventSocket wsEndPoint = new EventSocket();
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/ws/echo");
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/ws/echo/query?param=value");
Session session = wsClient.connect(wsEndPoint, uri).get(5, TimeUnit.SECONDS);

String text = "websocket";
Expand Down Expand Up @@ -391,6 +391,11 @@ private static class TestJettyWebSocketServlet extends JettyWebSocketServlet
protected void configure(JettyWebSocketServletFactory factory)
{
factory.addMapping("/ws/echo", (request, response) -> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void testWebSocketOverDynamicTransport(Function<ClientConnector, ClientC
startClient(protocolFn);

EventSocket wsEndPoint = new EventSocket();
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/ws/echo");
URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/ws/echo/query?param=value");
Session session = wsClient.connect(wsEndPoint, uri).get(5, TimeUnit.SECONDS);

String text = "websocket";
Expand Down Expand Up @@ -382,6 +382,11 @@ private static class TestJettyWebSocketServlet extends JettyWebSocketServlet
protected void configure(JettyWebSocketServletFactory factory)
{
factory.addMapping("/ws/echo", (request, response) -> 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");
Expand Down

0 comments on commit 581f9ae

Please sign in to comment.