Browse Source

Polishing contribution

Closes gh-32799
pull/33048/head
rstoyanchev 2 years ago
parent
commit
ea208dc304
  1. 9
      spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpRequest.java

9
spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpRequest.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,6 +37,7 @@ import org.springframework.http.HttpCookie;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
/** /**
* {@link ClientHttpRequest} for the Java {@link HttpClient}. * {@link ClientHttpRequest} for the Java {@link HttpClient}.
@ -108,7 +109,11 @@ class JdkClientHttpRequest extends AbstractClientHttpRequest {
@Override @Override
protected void applyCookies() { protected void applyCookies() {
this.builder.header(HttpHeaders.COOKIE, getCookies().values().stream() 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(";"))); .flatMap(List::stream).map(HttpCookie::toString).collect(Collectors.joining(";")));
} }

Loading…
Cancel
Save