@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2024 the original author or authors .
* Copyright 2002 - 2025 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -59,8 +59,9 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
@@ -59,8 +59,9 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
private final HttpRequest . Builder builder ;
public JdkClientHttpRequest ( HttpMethod httpMethod , URI uri , DataBufferFactory bufferFactory ,
@Nullable Duration readTimeout ) {
public JdkClientHttpRequest (
HttpMethod httpMethod , URI uri , DataBufferFactory bufferFactory , @Nullable Duration readTimeout ) {
Assert . notNull ( httpMethod , "HttpMethod is required" ) ;
Assert . notNull ( uri , "URI is required" ) ;
Assert . notNull ( bufferFactory , "DataBufferFactory is required" ) ;
@ -97,32 +98,6 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
@@ -97,32 +98,6 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
}
@Override
protected void applyHeaders ( ) {
for ( Map . Entry < String , List < String > > entry : getHeaders ( ) . headerSet ( ) ) {
if ( entry . getKey ( ) . equalsIgnoreCase ( HttpHeaders . CONTENT_LENGTH ) ) {
// content-length is specified when writing
continue ;
}
for ( String value : entry . getValue ( ) ) {
this . builder . header ( entry . getKey ( ) , value ) ;
}
}
if ( ! getHeaders ( ) . containsHeader ( HttpHeaders . ACCEPT ) ) {
this . builder . header ( HttpHeaders . ACCEPT , "*/*" ) ;
}
}
@Override
protected void applyCookies ( ) {
MultiValueMap < String , HttpCookie > cookies = getCookies ( ) ;
if ( cookies . isEmpty ( ) ) {
return ;
}
this . builder . header ( HttpHeaders . COOKIE , cookies . values ( ) . stream ( )
. flatMap ( List : : stream ) . map ( HttpCookie : : toString ) . collect ( Collectors . joining ( ";" ) ) ) ;
}
@Override
public Mono < Void > writeWith ( Publisher < ? extends DataBuffer > body ) {
return doCommit ( ( ) - > {
@ -162,4 +137,30 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
@@ -162,4 +137,30 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
} ) ;
}
@Override
protected void applyHeaders ( ) {
for ( Map . Entry < String , List < String > > entry : getHeaders ( ) . headerSet ( ) ) {
if ( entry . getKey ( ) . equalsIgnoreCase ( HttpHeaders . CONTENT_LENGTH ) ) {
// content-length is specified when writing
continue ;
}
for ( String value : entry . getValue ( ) ) {
this . builder . header ( entry . getKey ( ) , value ) ;
}
}
if ( ! getHeaders ( ) . containsHeader ( HttpHeaders . ACCEPT ) ) {
this . builder . header ( HttpHeaders . ACCEPT , "*/*" ) ;
}
}
@Override
protected void applyCookies ( ) {
MultiValueMap < String , HttpCookie > cookies = getCookies ( ) ;
if ( cookies . isEmpty ( ) ) {
return ;
}
this . builder . header ( HttpHeaders . COOKIE , cookies . values ( ) . stream ( )
. flatMap ( List : : stream ) . map ( HttpCookie : : toString ) . collect ( Collectors . joining ( ";" ) ) ) ;
}
}