|
|
|
|
@ -18,15 +18,19 @@ package org.springframework.http.client;
@@ -18,15 +18,19 @@ package org.springframework.http.client;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
|
|
|
|
import org.jspecify.annotations.Nullable; |
|
|
|
|
import org.junit.jupiter.api.AfterAll; |
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
import org.junit.jupiter.api.condition.EnabledForJreRange; |
|
|
|
|
import org.junit.jupiter.api.condition.JRE; |
|
|
|
|
|
|
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
|
import org.springframework.http.HttpStatusCode; |
|
|
|
|
import org.springframework.util.StreamUtils; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
@ -34,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -34,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
* Tests for {@link JdkClientHttpRequestFactory}. |
|
|
|
|
* |
|
|
|
|
* @author Marten Deinum |
|
|
|
|
* @author Brian Clozel |
|
|
|
|
*/ |
|
|
|
|
class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { |
|
|
|
|
|
|
|
|
|
@ -91,4 +96,22 @@ class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
@@ -91,4 +96,22 @@ class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-34971
|
|
|
|
|
@EnabledForJreRange(min = JRE.JAVA_19) // behavior fixed in Java 19
|
|
|
|
|
void requestContentLengthHeader() throws Exception { |
|
|
|
|
URI uri = URI.create(baseUrl + "/header/Content-Length"); |
|
|
|
|
assertNoContentLength(uri, HttpMethod.GET); |
|
|
|
|
assertNoContentLength(uri, HttpMethod.DELETE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void assertNoContentLength(URI uri, HttpMethod method) throws Exception { |
|
|
|
|
ClientHttpRequest request = factory.createRequest(uri, method); |
|
|
|
|
try (ClientHttpResponse response = request.execute()) { |
|
|
|
|
assertThat(response.getStatusCode()).as("Invalid response status").isEqualTo(HttpStatus.OK); |
|
|
|
|
assertThat(StreamUtils.copyToString(response.getBody(), StandardCharsets.ISO_8859_1)) |
|
|
|
|
.as("Invalid Content-Length request header").isEqualTo("Content-Length:null"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|