diff --git a/gradle.properties b/gradle.properties index e34fc17..a972173 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = netty-http -version = 4.1.51.4 +version = 4.1.51.5 gradle.wrapper.version = 6.4.1 netty.version = 4.1.51.Final diff --git a/netty-http-common/src/main/java/org/xbib/netty/http/common/HttpParameters.java b/netty-http-common/src/main/java/org/xbib/netty/http/common/HttpParameters.java index f5efd49..bb3fc16 100644 --- a/netty-http-common/src/main/java/org/xbib/netty/http/common/HttpParameters.java +++ b/netty-http-common/src/main/java/org/xbib/netty/http/common/HttpParameters.java @@ -27,7 +27,7 @@ import java.util.Map; * being useful for message signing; it's not a general purpose collection class * to handle request parameters. */ -public class HttpParameters extends /*LinkedHashSetMultiMap*/ CaseInsensitiveParameters { +public class HttpParameters extends CaseInsensitiveParameters { private static final String EQUALS = "="; diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java index c0dc56b..70be6f3 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/endpoint/HttpEndpoint.java @@ -92,7 +92,7 @@ public class HttpEndpoint implements Endpoint { .setEndpointResolver(endpointResolver) .setEndpoint((this)) .setContext(context); - String pattern = prefix + path; + String pattern = path; String effectiveRequestPath = serverRequestBuilder.getEffectiveRequestPath(); if (pathMatcher.match(pattern, effectiveRequestPath)) { QueryParameters queryParameters = pathMatcher.extractUriTemplateVariables(pattern, effectiveRequestPath); diff --git a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java index 84785ff..f3ad3f8 100644 --- a/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java +++ b/netty-http-server/src/test/java/org/xbib/netty/http/server/test/endpoint/EndpointTest.java @@ -30,6 +30,45 @@ class EndpointTest { private static final Logger logger = Logger.getLogger(EndpointTest.class.getName()); + @Test + void testPrefixPathParameter() throws Exception { + HttpAddress httpAddress = HttpAddress.http1("localhost", 8008); + HttpEndpointResolver httpEndpointResolver = HttpEndpointResolver.builder() + .setPrefix("/files") + .addEndpoint(HttpEndpoint.builder().setPath("/{mypath}").build()) + .setDispatcher((req, resp) -> { + logger.log(Level.INFO, "dispatching endpoint = " + req.getEndpoint() + + " req = " + req + + " req context path = " + req.getContextPath() + + " effective path = " + req.getEffectiveRequestPath() + + " path params = " + req.getPathParameters()); + assertEquals("test.txt", req.getPathParameters().get("mypath")); + }) + .build(); + HttpServerDomain domain = HttpServerDomain.builder(httpAddress) + .addEndpointResolver(httpEndpointResolver) + .build(); + Server server = Server.builder(domain) + .build(); + Client client = Client.builder() + .build(); + final AtomicBoolean success = new AtomicBoolean(false); + try { + server.accept(); + Request request = Request.get().setVersion(HttpVersion.HTTP_1_1) + .url(server.getServerConfig().getAddress().base().resolve("/files/test.txt")) + .setResponseListener(resp -> { + success.set(true); + }) + .build(); + client.execute(request).get(); + } finally { + server.shutdownGracefully(); + client.shutdownGracefully(); + logger.log(Level.INFO, "server and client shut down"); + } + } + @Test void testEmptyPrefixEndpoint() throws Exception { Path vartmp = Paths.get("/var/tmp/");