Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestClientResponseException handles responseHeaders case-sensitive #31978

Closed
MnlK opened this issue Jan 8, 2024 · 1 comment
Closed

RestClientResponseException handles responseHeaders case-sensitive #31978

MnlK opened this issue Jan 8, 2024 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@MnlK
Copy link

MnlK commented Jan 8, 2024

Starting with spring-web 6.1.2, the HttpHeaders supplied to RestClientResponseException are copied into a new LinkedMultiValueMap, that is not case-insensitive anymore.
Headers from getResponseHeaders() can then no longer be found without the correct case.

public RestClientResponseException(
		String message, HttpStatusCode statusCode, String statusText, @Nullable HttpHeaders headers,
		@Nullable byte[] responseBody, @Nullable Charset responseCharset) {
	...
	this.responseHeaders = copyHeaders(headers);
	...
}

private static HttpHeaders copyHeaders(@Nullable HttpHeaders headers) {
	if (headers != null) {
		MultiValueMap<String, String> result = new LinkedMultiValueMap<>(headers.size());
		headers.forEach((name, values) -> values.forEach(value -> result.add(name, value)));
		return HttpHeaders.readOnlyHttpHeaders(result);
	}
	else {
		return null;
	}
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 8, 2024
@bclozel
Copy link
Member

bclozel commented Jan 8, 2024

See #31787

@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 8, 2024
@bclozel bclozel added this to the 6.1.3 milestone Jan 8, 2024
@sbrannen sbrannen changed the title RestClientResponseException handles responseHeaders case-sensitive RestClientResponseException handles responseHeaders case-sensitive Jan 8, 2024
@poutsma poutsma self-assigned this Jan 8, 2024
@poutsma poutsma closed this as completed in e6f6381 Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants