Skip to content

Commit ef2c544

Browse files
authored
build(deps): bump reactor-netty to 1.2.9 (#622)
1 parent ac08669 commit ef2c544

File tree

3 files changed

+43
-20
lines changed

3 files changed

+43
-20
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ dependencies {
9797
implementation 'com.kjetland:mbknor-jackson-jsonschema_2.13:1.0.39'
9898
implementation 'com.jayway.jsonpath:json-path:2.9.0'
9999
implementation 'org.apache.httpcomponents.client5:httpclient5:5.5'
100-
implementation 'io.projectreactor.netty:reactor-netty-http:1.2.8'
100+
implementation 'io.projectreactor.netty:reactor-netty-http:1.2.9'
101101
implementation 'org.apache.maven:maven-artifact:3.9.11'
102102
implementation 'commons-codec:commons-codec:1.19.0'
103103
// for RFC5987 parsing of content-disposition filename*

src/main/java/me/itzg/helpers/http/SharedFetch.java

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,40 @@ public SharedFetch(String forCommand, Options options) {
5959
.pendingAcquireTimeout(options.getPendingAcquireTimeout())
6060
.build();
6161

62-
reactiveClient = HttpClient.create(connectionProvider)
63-
.proxyWithSystemProperties()
64-
.headers(headers -> {
65-
headers
66-
.set(HttpHeaderNames.USER_AGENT.toString(), userAgent)
67-
.set("x-fetch-session", fetchSessionId);
68-
if (options.getExtraHeaders() != null) {
69-
options.getExtraHeaders().forEach(headers::set);
70-
}
71-
}
72-
)
73-
// Reference https://projectreactor.io/docs/netty/release/reference/index.html#response-timeout
74-
.responseTimeout(options.getResponseTimeout());
62+
reactiveClient =
63+
applyWiretap(
64+
applyUseHttp2(
65+
HttpClient.create(connectionProvider)
66+
.proxyWithSystemProperties()
67+
.headers(headers -> {
68+
headers
69+
.set(HttpHeaderNames.USER_AGENT.toString(), userAgent)
70+
.set("x-fetch-session", fetchSessionId);
71+
if (options.getExtraHeaders() != null) {
72+
options.getExtraHeaders().forEach(headers::set);
73+
}
74+
}
75+
)
76+
// Reference https://projectreactor.io/docs/netty/release/reference/index.html#response-timeout
77+
.responseTimeout(options.getResponseTimeout()),
78+
options
79+
),
80+
options
81+
);
82+
83+
headers.put("x-fetch-session", fetchSessionId);
84+
85+
this.filesViaUrl = options.getFilesViaUrl();
86+
}
7587

88+
private HttpClient applyWiretap(HttpClient c, Options options) {
89+
return options.isWiretap() ? c.wiretap(true) : c;
90+
}
91+
92+
private HttpClient applyUseHttp2(HttpClient c, Options options) {
7693
if (options.isUseHttp2()) {
7794
log.debug("Using HTTP/2");
78-
reactiveClient
95+
return c
7996
// https://projectreactor.io/docs/netty/release/reference/http-client.html#HTTP2
8097
.protocol(HttpProtocol.HTTP11, HttpProtocol.H2)
8198
.secure(spec ->
@@ -87,17 +104,14 @@ public SharedFetch(String forCommand, Options options) {
87104
}
88105
else {
89106
log.debug("Using HTTP/1.1");
90-
reactiveClient
107+
return c
91108
.secure(spec ->
92109
spec.sslContext((GenericSslContextSpec<?>) Http11SslContextSpec.forClient())
93110
// Reference https://projectreactor.io/docs/netty/release/reference/index.html#ssl-tls-timeout
94111
.handshakeTimeout(options.getTlsHandshakeTimeout())
95112
);
96113
}
97114

98-
headers.put("x-fetch-session", fetchSessionId);
99-
100-
this.filesViaUrl = options.getFilesViaUrl();
101115
}
102116

103117
public FetchBuilderBase<?> fetch(URI uri) {
@@ -151,14 +165,16 @@ public static class Options {
151165
@Default
152166
private final boolean useHttp2 = true;
153167

168+
private final boolean wiretap;
169+
154170
public Options withHeader(String key, String value) {
155171
final Map<String, String> newHeaders = extraHeaders != null ?
156172
new HashMap<>(extraHeaders) : new HashMap<>();
157173
newHeaders.put(key, value);
158174

159175
return new Options(
160176
responseTimeout, tlsHandshakeTimeout, maxIdleTimeout, pendingAcquireTimeout,
161-
newHeaders, filesViaUrl, useHttp2
177+
newHeaders, filesViaUrl, useHttp2, wiretap
162178
);
163179
}
164180
}

src/main/java/me/itzg/helpers/http/SharedFetchArgs.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ public void setUseHttp2(boolean useHttp2) {
5555
optionsBuilder.useHttp2(useHttp2);
5656
}
5757

58+
@Option(names = "--wiretap", defaultValue = "${env:FETCH_WIRETAP:-false}",
59+
description = "Whether to enable Reactor Netty wiretap logging. Default: ${DEFAULT-VALUE}"
60+
)
61+
public void setWiretap(boolean wiretap) {
62+
optionsBuilder.wiretap(wiretap);
63+
}
64+
5865
public Options options() {
5966
return optionsBuilder.build();
6067
}

0 commit comments

Comments
 (0)