Skip to content

Update TestRestTemplate's default cookie handling to match RestTemplate's#49261

Open
apoorvdarshan wants to merge 1 commit intospring-projects:mainfrom
apoorvdarshan:fix/testresttemplate-default-cookie-handling
Open

Update TestRestTemplate's default cookie handling to match RestTemplate's#49261
apoorvdarshan wants to merge 1 commit intospring-projects:mainfrom
apoorvdarshan:fix/testresttemplate-default-cookie-handling

Conversation

@apoorvdarshan
Copy link

@apoorvdarshan apoorvdarshan commented Feb 18, 2026

Summary

  • TestRestTemplate previously disabled cookies by default (StandardCookieSpec.IGNORE), differing from RestTemplate which uses the HTTP client library's default
  • Aligns the defaults so TestRestTemplate no longer explicitly ignores cookies
  • Adds withCookies(HttpCookies) method for explicit cookie control, following the same pattern as withRedirects(HttpRedirects) from Align TestRestTemplate default redirect settings to be the same as RestTemplate #43431
  • Introduces HttpCookies enum, HttpComponentsCookieSpec adapter, and cookies() on RestTemplateBuilder
  • Deprecates HttpClientOption.ENABLE_COOKIES

Fixes gh-48607

Test plan

  • TestRestTemplateTests — verifies default cookie spec is now null (library default), withCookies(ENABLE) returns "strict", withCookies(DISABLE) returns "ignoreCookies"
  • HttpClientSettingsTests — verifies withCookies() and updated orElse() with cookies field
  • HttpClientAutoConfigurationTests — verifies settings construction with new record shape
  • Existing redirect tests remain green

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 18, 2026
…te's

Signed-off-by: Apoorv Darshan <ad13dtu@gmail.com>
@apoorvdarshan apoorvdarshan force-pushed the fix/testresttemplate-default-cookie-handling branch from dff9449 to 7e42613 Compare February 19, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update TestRestTemplate's default cookie handling to be the same as RestTemplate's

2 participants

Comments