Skip to content

Commit a726670

Browse files
Deprecate HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY (#2722)
Motivation: Prior to `ConnectionObserver.ProxyConnectObserver` added in #2711, the sequence of `ConnectionObserver` events was different between regular connections and connection to the proxy tunnels. `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` (#2169) was useful to distinguish when the correct callback inside `ConnectionObserver` before reporting that a new connection is ready to take traffic. After adding `ProxyConnectObserver`, there is no need in this custom key. Modifications: - Deprecate `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` and describe what is an appropriate replacement for users; Result: We will be able to remove `HttpContextKeys.HTTP_TARGET_ADDRESS_BEHIND_PROXY` in the future releases.
1 parent 2aacf9e commit a726670

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

servicetalk-http-api/src/main/java/io/servicetalk/http/api/HttpContextKeys.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616
package io.servicetalk.http.api;
1717

18+
import io.servicetalk.client.api.TransportObserverConnectionFactoryFilter;
1819
import io.servicetalk.context.api.ContextMap;
1920
import io.servicetalk.context.api.ContextMap.Key;
2021
import io.servicetalk.transport.api.ConnectionInfo;
22+
import io.servicetalk.transport.api.ConnectionObserver;
23+
import io.servicetalk.transport.api.TransportObserver;
2124

2225
import static io.servicetalk.context.api.ContextMap.Key.newKey;
2326

@@ -43,8 +46,15 @@ public final class HttpContextKeys {
4346
* HTTP proxy tunneling</a> and a clear text HTTP proxy, check presence of {@link ConnectionInfo#sslConfig()}.
4447
*
4548
* @see SingleAddressHttpClientBuilder#proxyAddress(Object)
49+
* @deprecated Use {@link TransportObserverConnectionFactoryFilter} to configure {@link TransportObserver} and then
50+
* listen {@link ConnectionObserver#onProxyConnect(Object)} callback to distinguish between a regular connection and
51+
* a connection to the secure HTTP proxy tunnel. For clear text HTTP proxies, consider installing a custom client
52+
* filter that will populate {@link HttpRequestMetaData#context()} with a similar key or reach out to the
53+
* ServiceTalk developers to discuss ideas.
4654
*/
47-
public static final Key<Object> HTTP_TARGET_ADDRESS_BEHIND_PROXY =
55+
@Deprecated
56+
@SuppressWarnings("DeprecatedIsStillUsed")
57+
public static final Key<Object> HTTP_TARGET_ADDRESS_BEHIND_PROXY = // FIXME: 0.43 - remove deprecated constant
4858
newKey("HTTP_TARGET_ADDRESS_BEHIND_PROXY", Object.class);
4959

5060
/**

servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/AbsoluteAddressHttpRequesterFilter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public HttpExecutionStrategy requiredOffloads() {
8989
return HttpExecutionStrategies.offloadNone();
9090
}
9191

92+
@SuppressWarnings("deprecation")
9293
private Single<StreamingHttpResponse> request(final StreamingHttpRequester delegate,
9394
final StreamingHttpRequest request) {
9495
return defer(() -> {

servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/DefaultSingleAddressHttpClientBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public HttpExecutionStrategy executionStrategy() {
241241

242242
if (roConfig.hasProxy() && sslContext != null) {
243243
assert roConfig.connectAddress() != null;
244+
@SuppressWarnings("deprecation")
244245
final ConnectionFactoryFilter<R, FilterableStreamingHttpConnection> proxy =
245246
new ProxyConnectConnectionFactoryFilter<>(roConfig.connectAddress(), connectionFactoryStrategy);
246247
assert !proxy.requiredOffloads().hasOffloads();

servicetalk-http-netty/src/main/java/io/servicetalk/http/netty/ProxyConnectConnectionFactoryFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
*
4747
* @param <ResolvedAddress> The type of resolved addresses that can be used for connecting.
4848
* @param <C> The type of connections created by this factory.
49+
* @deprecated This filter won't be required after {@link HttpContextKeys#HTTP_TARGET_ADDRESS_BEHIND_PROXY} is removed.
4950
*/
51+
@Deprecated // FIXME: 0.43 - remove deprecated class
52+
@SuppressWarnings("DeprecatedIsStillUsed")
5053
final class ProxyConnectConnectionFactoryFilter<ResolvedAddress, C extends FilterableStreamingHttpConnection>
5154
implements ConnectionFactoryFilter<ResolvedAddress, C> {
5255

@@ -70,6 +73,7 @@ private ProxyFilter(final ConnectionFactory<ResolvedAddress, C> delegate) {
7073
}
7174

7275
@Override
76+
@SuppressWarnings("deprecation")
7377
public Single<C> newConnection(final ResolvedAddress resolvedAddress,
7478
@Nullable ContextMap context,
7579
@Nullable final TransportObserver observer) {
@@ -84,6 +88,7 @@ public Single<C> newConnection(final ResolvedAddress resolvedAddress,
8488
}
8589
}
8690

91+
@SuppressWarnings("deprecation")
8792
static void logUnexpectedAddress(@Nullable final Object current, final Object expected, final Logger logger) {
8893
if (current != null && !expected.equals(current)) {
8994
logger.info("Observed unexpected value for {}: {}, overridden with: {}",

0 commit comments

Comments
 (0)