Skip to content

Set the sameSite cookie attribute in ClientHttpResponse implementations #25785

@DamianFekete

Description

@DamianFekete

Affects: Spring Framework 5.2.9 (and below)

I would like to have direct access to the sameSite attribute when using WebTestClient (body.getResponseCookies()).

ReactorClientHttpResponse#getCookies() doesn't set the sameSite attribute on the ResponseCookie.

this.response.cookies().values().stream().flatMap(Collection::stream)
	.forEach(c ->

		result.add(c.name(), ResponseCookie.fromClientResponse(c.name(), c.value())
				.domain(c.domain())
				.path(c.path())
				.maxAge(c.maxAge())
				.secure(c.isSecure())
				.httpOnly(c.isHttpOnly())
				.build()));

this.response.cookies() returns a io.netty.handler.codec.http.cookie.Cookie (the interface), but the implementation is io.netty.handler.codec.http.cookie.DefaultCookie, which supports the sameSite attribute.

Is there any compelling reason not to test if the implementation is DefaultCookie and if it is to set the sameSite attribute on the returned ResponseCookie ?

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions