fix mutator() calls in URL building
This commit is contained in:
parent
28cdfcfb57
commit
c3d65df2e0
3 changed files with 10 additions and 10 deletions
|
@ -1,13 +1,13 @@
|
|||
group = org.xbib
|
||||
name = netty-http
|
||||
version = 4.1.38.1
|
||||
version = 4.1.38.2
|
||||
|
||||
# main packages
|
||||
netty.version = 4.1.38.Final
|
||||
tcnative.version = 2.0.25.Final
|
||||
|
||||
# common
|
||||
xbib-net-url.version = 1.3.3
|
||||
xbib-net-url.version = 1.3.4
|
||||
|
||||
# server
|
||||
bouncycastle.version = 1.61
|
||||
|
|
|
@ -39,6 +39,7 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
|
@ -520,9 +521,6 @@ public class Request {
|
|||
if (url == null) {
|
||||
throw new IllegalStateException("URL not set");
|
||||
}
|
||||
if (url.getHost() == null) {
|
||||
throw new IllegalStateException("host in URL not defined: " + url);
|
||||
}
|
||||
// form parameters
|
||||
if (!formParameters.isEmpty()) {
|
||||
try {
|
||||
|
@ -533,9 +531,10 @@ public class Request {
|
|||
}
|
||||
}
|
||||
// attach user query parameters to URL
|
||||
URL.Builder builder = url.newBuilder();
|
||||
uriParameters.forEach((k, v) -> v.forEach(value -> builder.queryParam(k, value)));
|
||||
url = builder.build();
|
||||
URL.Builder mutator = url.mutator();
|
||||
uriParameters.forEach((k, v) -> v.forEach(value -> mutator.queryParam(k, value)));
|
||||
url = mutator.build();
|
||||
Objects.requireNonNull(url.getHost());
|
||||
// let Netty's query string decoder/encoder work over the URL to add parameters given implicitly in url()
|
||||
String path = url.getPath();
|
||||
String query = url.getQuery();
|
||||
|
|
|
@ -225,7 +225,7 @@ class EndpointTest {
|
|||
client.execute(request).get();
|
||||
Request request1 = Request.get().setVersion(HttpVersion.HTTP_1_1)
|
||||
.url(server.getServerConfig().getAddress().base()
|
||||
.resolve("/static1/test1.txt").newBuilder().fragment("frag").build())
|
||||
.resolve("/static1/test1.txt").mutator().fragment("frag").build())
|
||||
.build()
|
||||
.setResponseListener(resp -> {
|
||||
if (resp.getStatus().getCode() == HttpResponseStatus.OK.code()) {
|
||||
|
@ -237,7 +237,8 @@ class EndpointTest {
|
|||
});
|
||||
client.execute(request1).get();
|
||||
Request request2 = Request.get().setVersion(HttpVersion.HTTP_1_1)
|
||||
.url(server.getServerConfig().getAddress().base().resolve("/static2/test2.txt"))
|
||||
.url(server.getServerConfig().getAddress().base()
|
||||
.resolve("/static2/test2.txt"))
|
||||
.content("{\"a\":\"b\"}","application/json")
|
||||
.build()
|
||||
.setResponseListener(resp -> {
|
||||
|
|
Loading…
Reference in a new issue