* Do NOT perform any blocking operations in any of these methods. A typical example would be trying to send another
* request and calling get() on its future.
- * There's a chance you might end up in a dead lock.
+ * There's a chance you might end up in a deadlock.
* If you really need to perform a blocking operation, execute it in a different dedicated thread pool.
*
* @param
- * Might be called several times if the name was resolved to multiple addresses and we failed to connect to the first(s) one(s).
+ * Might be called several times if the name was resolved to multiple addresses, and we failed to connect to the first(s) one(s).
*
* @param remoteAddress the address we try to connect to
*/
diff --git a/client/src/main/java/org/asynchttpclient/AsyncHttpClient.java b/client/src/main/java/org/asynchttpclient/AsyncHttpClient.java
index 9e86b9f84..01a3ecf73 100755
--- a/client/src/main/java/org/asynchttpclient/AsyncHttpClient.java
+++ b/client/src/main/java/org/asynchttpclient/AsyncHttpClient.java
@@ -66,7 +66,7 @@
* The {@link AsyncCompletionHandler#onCompleted(Response)} method will be invoked once the http response has been fully read.
* The {@link Response} object includes the http headers and the response body. Note that the entire response will be buffered in memory.
*
* If false (default), AHC will either leave AcceptEncoding header as is
* (if enableAutomaticDecompression is false) or will remove unsupported
* algorithms (if enableAutomaticDecompression is true)
@@ -988,7 +1008,6 @@ public Builder setCompressionEnforced(boolean compressionEnforced) {
return this;
}
-
/*
* If true (default), AHC will add a Netty HttpContentDecompressor, so compressed
* content will automatically get decompressed.
@@ -997,7 +1016,7 @@ public Builder setCompressionEnforced(boolean compressionEnforced) {
* be done by calling code.
*/
public Builder setEnableAutomaticDecompression(boolean enable) {
- this.enableAutomaticDecompression = enable;
+ enableAutomaticDecompression = enable;
return this;
}
@@ -1070,6 +1089,11 @@ public Builder setUseProxyProperties(boolean useProxyProperties) {
return this;
}
+ public Builder setStripAuthorizationOnRedirect(boolean value) {
+ stripAuthorizationOnRedirect = value;
+ return this;
+ }
+
// websocket
public Builder setAggregateWebSocketFrameFragments(boolean aggregateWebSocketFrameFragments) {
this.aggregateWebSocketFrameFragments = aggregateWebSocketFrameFragments;
@@ -1435,6 +1459,7 @@ public DefaultAsyncHttpClientConfig build() {
validateResponseHeaders,
aggregateWebSocketFrameFragments,
enablewebSocketCompression,
+ stripAuthorizationOnRedirect,
connectTimeout,
requestTimeout,
readTimeout,
diff --git a/client/src/main/java/org/asynchttpclient/DefaultRequest.java b/client/src/main/java/org/asynchttpclient/DefaultRequest.java
index 4170c33e2..09c615d2a 100644
--- a/client/src/main/java/org/asynchttpclient/DefaultRequest.java
+++ b/client/src/main/java/org/asynchttpclient/DefaultRequest.java
@@ -15,6 +15,7 @@
*/
package org.asynchttpclient;
+import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.resolver.NameResolver;
@@ -51,6 +52,7 @@ public class DefaultRequest implements Request {
private final @Nullable List
- * You can also have more control about the how the response is asynchronously processed by using an {@link AsyncHandler}
+ * You can also have more control about how the response is asynchronously processed by using an {@link AsyncHandler}
*
* AsyncHttpClient c = new AsyncHttpClient();
* Future<String> f = c.prepareGet(TARGET_URL).execute(new AsyncHandler<String>() {
@@ -149,7 +149,7 @@ public interface AsyncHttpClient extends Closeable {
* Prepare an HTTP client request.
*
* @param method HTTP request method type. MUST BE in upper case
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepare(String method, String url);
@@ -158,7 +158,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client GET request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareGet(String url);
@@ -166,7 +166,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client CONNECT request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareConnect(String url);
@@ -174,7 +174,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client OPTIONS request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareOptions(String url);
@@ -182,7 +182,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client HEAD request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareHead(String url);
@@ -190,7 +190,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client POST request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePost(String url);
@@ -198,7 +198,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client PUT request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePut(String url);
@@ -206,7 +206,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client DELETE request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareDelete(String url);
@@ -214,7 +214,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client PATCH request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder preparePatch(String url);
@@ -222,7 +222,7 @@ public interface AsyncHttpClient extends Closeable {
/**
* Prepare an HTTP client TRACE request.
*
- * @param url A well formed URL.
+ * @param url A well-formed URL.
* @return {@link RequestBuilder}
*/
BoundRequestBuilder prepareTrace(String url);
diff --git a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
index 972fa0b3a..954628b3d 100644
--- a/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
+++ b/client/src/main/java/org/asynchttpclient/AsyncHttpClientConfig.java
@@ -160,7 +160,8 @@ public interface AsyncHttpClientConfig {
* @return the {@link ThreadFactory} an {@link AsyncHttpClient} use for handling asynchronous response. If no {@link ThreadFactory} has been explicitly
* provided, this method will return {@code null}
*/
- @Nullable ThreadFactory getThreadFactory();
+ @Nullable
+ ThreadFactory getThreadFactory();
/**
* An instance of {@link ProxyServer} used by an {@link AsyncHttpClient}
@@ -174,14 +175,16 @@ public interface AsyncHttpClientConfig {
*
* @return an instance of {@link SslContext} used for SSL connection.
*/
- @Nullable SslContext getSslContext();
+ @Nullable
+ SslContext getSslContext();
/**
* Return the current {@link Realm}
*
* @return the current {@link Realm}
*/
- @Nullable Realm getRealm();
+ @Nullable
+ Realm getRealm();
/**
* Return the list of {@link RequestFilter}
@@ -231,7 +234,7 @@ public interface AsyncHttpClientConfig {
boolean isDisableUrlEncodingForBoundRequests();
/**
- * @return true if AHC is to use a LAX cookie encoder, eg accept illegal chars in cookie value
+ * @return true if AHC is to use a LAX cookie encoder, e.g. accept illegal chars in cookie value
*/
boolean isUseLaxCookieEncoder();
@@ -260,12 +263,14 @@ public interface AsyncHttpClientConfig {
/**
* @return the array of enabled protocols
*/
- @Nullable String[] getEnabledProtocols();
+ @Nullable
+ String[] getEnabledProtocols();
/**
* @return the array of enabled cipher suites
*/
- @Nullable String[] getEnabledCipherSuites();
+ @Nullable
+ String[] getEnabledCipherSuites();
/**
* @return if insecure cipher suites must be filtered out (only used when not explicitly passing enabled cipher suites)
@@ -294,7 +299,8 @@ public interface AsyncHttpClientConfig {
int getHandshakeTimeout();
- @Nullable SslEngineFactory getSslEngineFactory();
+ @Nullable
+ SslEngineFactory getSslEngineFactory();
int getChunkedFileChunkSize();
@@ -310,23 +316,29 @@ public interface AsyncHttpClientConfig {
Map
* There is no guaranteed ordering of execution of listeners, they may get
- * called in the order they were added and they may get called out of order,
+ * called in the order they were added, and they may get called out of order,
* but any listener added through this method is guaranteed to be called once
* the computation is complete.
*
diff --git a/client/src/main/java/org/asynchttpclient/Param.java b/client/src/main/java/org/asynchttpclient/Param.java
index cbc35e196..4f7a5530a 100644
--- a/client/src/main/java/org/asynchttpclient/Param.java
+++ b/client/src/main/java/org/asynchttpclient/Param.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2023 AsyncHttpClient Project. All rights reserved.
+ * Copyright (c) 2014-2024 AsyncHttpClient Project. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/client/src/main/java/org/asynchttpclient/Realm.java b/client/src/main/java/org/asynchttpclient/Realm.java
index 2006bd8b8..c6b70a7de 100644
--- a/client/src/main/java/org/asynchttpclient/Realm.java
+++ b/client/src/main/java/org/asynchttpclient/Realm.java
@@ -29,7 +29,7 @@
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.asynchttpclient.util.Assertions.assertNotNull;
+import static java.util.Objects.requireNonNull;
import static org.asynchttpclient.util.HttpConstants.Methods.GET;
import static org.asynchttpclient.util.MessageDigestUtils.pooledMd5MessageDigest;
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
@@ -92,7 +92,7 @@ private Realm(@Nullable AuthScheme scheme,
@Nullable Map