Skip to content

Commit

Permalink
Merge pull request #15363 from stuartwdouglas/uri-info-bu
Browse files Browse the repository at this point in the history
Fix issue with double query params
  • Loading branch information
geoand authored Mar 1, 2021
2 parents 170bf61 + 4b06c55 commit 4058da7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import org.hamcrest.Matchers;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
Expand All @@ -27,6 +28,7 @@
import io.quarkus.resteasy.reactive.server.test.resource.basic.resource.UriInfoSimpleSingletonResource;
import io.quarkus.resteasy.reactive.server.test.simple.PortProviderUtil;
import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

/**
* @tpSubChapter Resources
Expand Down Expand Up @@ -77,6 +79,9 @@ public static void after() throws Exception {
public void testUriInfo() throws Exception {
basicTest("/simple", UriInfoSimpleResource.class.getSimpleName());
basicTest("/simple/fromField", UriInfoSimpleResource.class.getSimpleName());

RestAssured.get("/" + UriInfoSimpleResource.class.getSimpleName() + "/uri?foo=bar").then()
.body(Matchers.endsWith("/uri?foo=bar"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public String get(@Context UriInfo info, @QueryParam("abs") String abs) {
return "CONTENT";
}

@Path("/uri")
@GET
public String get(@Context UriInfo info) {
return info.getRequestUri().toASCIIString();
}

@Path("/simple/fromField")
@GET
public String getField(@QueryParam("abs") String abs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public URI getRequestUri() {
ServerHttpRequest request = currentRequest.serverRequest();
try {
// TCK says normalized
requestUri = new URI(currentRequest.getAbsoluteURI() + (request.query() == null ? "" : "?" + request.query()))
requestUri = new URI(currentRequest.getAbsoluteURI())
.normalize();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 4058da7

Please sign in to comment.