Skip to content

Commit 395c9bd

Browse files
committed
Consistently call HttpURLConnection.setFixedLengthStreamingMode(long)
Issue: SPR-16404
1 parent 142f1ab commit 395c9bd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,13 +30,15 @@
3030
import org.springframework.util.concurrent.ListenableFuture;
3131

3232
/**
33-
* {@link org.springframework.http.client.ClientHttpRequest} implementation that uses
34-
* standard Java facilities to execute streaming requests. Created via the {@link
35-
* org.springframework.http.client.SimpleClientHttpRequestFactory}.
33+
* {@link org.springframework.http.client.ClientHttpRequest} implementation
34+
* that uses standard Java facilities to execute streaming requests. Created
35+
* via the {@link org.springframework.http.client.SimpleClientHttpRequestFactory}.
3636
*
3737
* @author Arjen Poutsma
3838
* @since 3.0
3939
* @see org.springframework.http.client.SimpleClientHttpRequestFactory#createRequest
40+
* @see org.springframework.http.client.support.AsyncHttpAccessor
41+
* @see org.springframework.web.client.AsyncRestTemplate
4042
* @deprecated as of Spring 5.0, with no direct replacement
4143
*/
4244
@Deprecated
@@ -84,7 +86,7 @@ public URI getURI() {
8486
protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
8587
if (this.body == null) {
8688
if (this.outputStreaming) {
87-
int contentLength = (int) headers.getContentLength();
89+
long contentLength = headers.getContentLength();
8890
if (contentLength >= 0) {
8991
this.connection.setFixedLengthStreamingMode(contentLength);
9092
}

spring-web/src/main/java/org/springframework/http/client/SimpleStreamingClientHttpRequest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@
3434
* @author Arjen Poutsma
3535
* @since 3.0
3636
* @see SimpleClientHttpRequestFactory#createRequest(java.net.URI, HttpMethod)
37+
* @see org.springframework.http.client.support.HttpAccessor
38+
* @see org.springframework.web.client.RestTemplate
3739
*/
3840
final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest {
3941

0 commit comments

Comments
 (0)