Skip to content

4.0.10: Retrieve the correct requested URI info path value, indpt of the routing path used to locate the handler #8844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private UriInfo createUriInfo() {
.orElse(DEFAULT_REQUESTED_URI_DISCOVERY_CONTEXT)
.uriInfo(remotePeer().address().toString(),
localPeer().address().toString(),
path.path(),
path.absolute().path(),
headers,
query(),
isSecure());
Expand Down
1 change: 1 addition & 0 deletions webserver/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<module>imperative</module>
<module>mtls</module>
<module>observe</module>
<module>requested-uri-path-gh8818</module>
<module>resource-limits</module>
<module>sse</module>
<module>static-content</module>
Expand Down
60 changes: 60 additions & 0 deletions webserver/tests/requested-uri-path-gh8818/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2024 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.webserver.tests</groupId>
<artifactId>helidon-webserver-tests-project</artifactId>
<version>4.0.10-SNAPSHOT</version>
</parent>

<artifactId>helidon-webserver-tests-requested-uri-path-gh8818</artifactId>
<name>Helidon WebServer Tests Requested URI Path GH 8818</name>

<dependencies>
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver-static-content</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.webserver.testing.junit5</groupId>
<artifactId>helidon-webserver-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.logging</groupId>
<artifactId>helidon-logging-jul</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.webserver.tests.gh2631;

import io.helidon.logging.common.LogConfig;
import io.helidon.webserver.WebServer;
import io.helidon.webserver.http.HttpRouting;
import io.helidon.webserver.http.HttpRules;
import io.helidon.webserver.http.HttpService;
import io.helidon.webserver.http.ServerRequest;
import io.helidon.webserver.http.ServerResponse;

public class Gh8818 {

static final String ENDPOINT_PATH = "/greet";

public static void main(String[] args) {
startServer();
}

static WebServer startServer() {
return WebServer.builder()
.routing(Gh8818::routing)
.build()
.start();
}

static void routing(HttpRouting.Builder routing) {
LogConfig.configureRuntime();

routing.register(ENDPOINT_PATH, new TestResource());
}

private static class TestResource implements HttpService {

@Override
public void routing(HttpRules httpRules) {
httpRules.get("/", this::getDefaultMessageHandler);
}

private void getDefaultMessageHandler(ServerRequest serverRequest,
ServerResponse serverResponse) {
serverResponse.send(serverRequest.requestedUri().path().path());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

handlers=io.helidon.logging.jul.HelidonConsoleHandler
java.util.logging.SimpleFormatter.format=%4$s %3$s: %5$s%6$s%n

.level=INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.helidon.webserver.tests.gh2631;

import io.helidon.webclient.http1.Http1Client;
import io.helidon.webserver.http.HttpRouting;
import io.helidon.webserver.testing.junit5.ServerTest;
import io.helidon.webserver.testing.junit5.SetUpRoute;

import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

@ServerTest
class Gh8818Test {

private Http1Client client;

Gh8818Test(Http1Client client) {
this.client = client;
}

@SetUpRoute
static void setupRoute(HttpRouting.Builder routing) {
Gh8818.routing(routing);
}

@Test
void checkForFullPath() {
String requestedPath = get(Gh8818.ENDPOINT_PATH);
assertThat("Requested path", requestedPath, is(Gh8818.ENDPOINT_PATH));
}

private String get(String path) {
return client.get()
.path(path)
.requestEntity(String.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private UriInfo createUriInfo() {
.orElse(DEFAULT_REQUESTED_URI_DISCOVERY_CONTEXT)
.uriInfo(remotePeer().address().toString(),
localPeer().address().toString(),
path.path(),
path.absolute().path(),
headers,
query(),
isSecure());
Expand Down