mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Do not send null HTTP header value in JdkClientHttpRequest
Prior to this commit, the `JdkClientHttpRequest` would add all values from `HttpHeaders` to the native request builder. This could cause `NullPointerException` being thrown at runtime because the `HttpClient` does not support that. This commit replicates a fix that was applied to the `SimpleClientHttpRequest`, turning null values into empty "". Fixes gh-35996
This commit is contained in:
@@ -155,7 +155,7 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
|
||||
headers.forEach((headerName, headerValues) -> {
|
||||
if (!DISALLOWED_HEADERS.contains(headerName.toLowerCase(Locale.ROOT))) {
|
||||
for (String headerValue : headerValues) {
|
||||
builder.header(headerName, headerValue);
|
||||
builder.header(headerName, (headerValue != null) ? headerValue : "");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class OkHttp3ClientHttpRequest extends AbstractStreamingClientHttpRequest {
|
||||
builder.method(this.method.name(), requestBody);
|
||||
headers.forEach((headerName, headerValues) -> {
|
||||
for (String headerValue : headerValues) {
|
||||
builder.addHeader(headerName, headerValue);
|
||||
builder.addHeader(headerName, (headerValue != null) ? headerValue : "");
|
||||
}
|
||||
});
|
||||
Request request = builder.build();
|
||||
|
||||
Reference in New Issue
Block a user