Skip to content

Commit

Permalink
Merge pull request #25353 from gastaldi/reactive-rest-client
Browse files Browse the repository at this point in the history
Use encoded request path in rest-client-reactive
  • Loading branch information
geoand committed May 4, 2022
2 parents d5de3c3 + 63e087e commit a152f8c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public RequestOptions apply(ServiceInstance serviceInstance) {

return requestOptions.onItem()
.transform(r -> r.setMethod(HttpMethod.valueOf(state.getHttpMethod()))
.setURI(uri.getPath() + (uri.getRawQuery() == null ? "" : "?" + uri.getRawQuery()))
.setURI(uri.getRawPath() + (uri.getRawQuery() == null ? "" : "?" + uri.getRawQuery()))
.setFollowRedirects(followRedirects))
.onItem().invoke(r -> {
if (readTimeout instanceof Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void init(@Observes Router router) {
}
rc.end(exception);
});

router.get("/with%20space").handler(rc -> rc.response().setStatusCode(200).end());
}

private Future<Void> success(RoutingContext rc, String body) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkus.it.rest.client;

import static org.assertj.core.api.Assertions.assertThat;

import javax.ws.rs.client.ClientBuilder;

import org.junit.jupiter.api.Test;

import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class RequestEncodingTest {

private static final String ENCODED_PATH = "/with%20space";
private static final String DECODED_PATH = "/with space";

@TestHTTPResource("/")
String root;

@Test
void testEncodedPath() throws Exception {
var request = ClientBuilder.newClient().target(root + ENCODED_PATH).request();
try (var response = request.get()) {
assertThat(response.getStatus())
.as("Unexpected HTTP status with message %s", response.readEntity(String.class))
.isEqualTo(200);
}
}

@Test
void testDecodedPath() throws Exception {
var request = ClientBuilder.newClient().target(root + DECODED_PATH).request();
try (var response = request.get()) {
assertThat(response.getStatus())
.as("Unexpected HTTP status with message %s", response.readEntity(String.class))
.isEqualTo(200);
}
}

}

0 comments on commit a152f8c

Please sign in to comment.