Skip to content

Commit

Permalink
Drops skip encoding setting in connector after fixing handling of + i…
Browse files Browse the repository at this point in the history
…n ClientUri query string.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
  • Loading branch information
spericas committed Feb 2, 2024
1 parent b10b661 commit dd32527
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ private HttpClientRequest mapRequest(ClientRequest request) {
HttpClientRequest httpRequest = webClient
.method(Method.create(request.getMethod()))
.proxy(requestProxy)
.skipUriEncoding(true) // already encoded by Jersey
.uri(uri);

// map request headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.URI;

import io.helidon.common.uri.UriEncoding;
import io.helidon.common.uri.UriFragment;
import io.helidon.common.uri.UriInfo;
import io.helidon.common.uri.UriPath;
Expand Down Expand Up @@ -194,8 +195,11 @@ public ClientUri resolve(URI uri) {

uriBuilder.path(resolvePath(uriBuilder.path().path(), uri.getPath()));

if (uri.getQuery() != null) {
query.fromQueryString(uri.getQuery());
String queryString = uri.getQuery();
if (queryString != null) {
// class URI does not decode +'s so we do it
query.fromQueryString(queryString.indexOf('+') >= 0 ?
UriEncoding.decodeUri(queryString) : queryString);
}

if (uri.getRawFragment() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand All @@ -20,7 +20,6 @@

import io.helidon.common.uri.UriPath;
import io.helidon.common.uri.UriQueryWriteable;

import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -105,4 +104,23 @@ void testResolveAll() {
assertThat(helper.port(), is(80));
assertThat(helper.scheme(), is("https"));
}

@Test
void testResolveQuery() {
URI uri = URI.create("http://localhost:8080/greet?filter=a+b+c");
ClientUri clientUri = ClientUri.create();
clientUri.resolve(uri);
assertThat(clientUri.query().get("filter"), is("a b c"));
assertThat(clientUri.query().getRaw("filter"), is("a%20b%20c"));
}

@Test
void testToUriWithSkipEncoding() {
URI uri = URI.create("http://localhost:8080/greet?filter=%20a%20");
ClientUri clientUri = ClientUri.create();
clientUri.skipUriEncoding(true);
clientUri.resolve(uri);
URI newUri = clientUri.toUri();
assertThat(uri, is(newUri));
}
}

0 comments on commit dd32527

Please sign in to comment.