Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/src/main/java/org/asynchttpclient/Realm.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ public int getMaxIterationCount() {

/**
* Returns the lazily computed and cached HTTP Basic authorization header for this immutable realm.
* Concurrent first calls may compute the same value more than once.
* Always encodes {@link #getPrincipal()} and {@link #getPassword()} as a Basic header, regardless
* of {@link #getScheme()}. Concurrent first calls may compute the same value more than once.
*
* @return the Basic authorization header
* @since 3.0.12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -66,6 +67,19 @@ void preemptiveBasicAuthorizationHeaderIsMemoizedOnRealm() {
assertSame(first, proxy);
}

@Test
void basicAuthHeaderCacheIsNotSharedAcrossRealms() {
Realm realmA = new Realm.Builder("user", "pass")
.setScheme(Realm.AuthScheme.BASIC)
.build();
Realm realmB = new Realm.Builder("user", "pass")
.setScheme(Realm.AuthScheme.BASIC)
.build();

assertEquals(realmA.getBasicAuthHeader(), realmB.getBasicAuthHeader());
assertNotSame(realmA.getBasicAuthHeader(), realmB.getBasicAuthHeader());
}

@Test
void computeBodyHashEmptyBody() throws Exception {
Request request = new RequestBuilder("GET")
Expand Down
Loading