Consistent headers.getContentLength() checks
(cherry picked from commit 7f438dc)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -43,7 +43,7 @@ abstract class AbstractBufferingAsyncClientHttpRequest extends AbstractAsyncClie
|
||||
@Override
|
||||
protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers) throws IOException {
|
||||
byte[] bytes = this.bufferedOutput.toByteArray();
|
||||
if (headers.getContentLength() == -1) {
|
||||
if (headers.getContentLength() < 0) {
|
||||
headers.setContentLength(bytes.length);
|
||||
}
|
||||
ListenableFuture<ClientHttpResponse> result = executeInternal(headers, bytes);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -42,7 +42,7 @@ abstract class AbstractBufferingClientHttpRequest extends AbstractClientHttpRequ
|
||||
@Override
|
||||
protected ClientHttpResponse executeInternal(HttpHeaders headers) throws IOException {
|
||||
byte[] bytes = this.bufferedOutput.toByteArray();
|
||||
if (headers.getContentLength() == -1) {
|
||||
if (headers.getContentLength() < 0) {
|
||||
headers.setContentLength(bytes.length);
|
||||
}
|
||||
ClientHttpResponse result = executeInternal(headers, bytes);
|
||||
|
||||
@@ -132,7 +132,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
this.headers.setContentType(newContentType);
|
||||
}
|
||||
}
|
||||
if (this.headers.getContentLength() == -1) {
|
||||
if (this.headers.getContentLength() < 0) {
|
||||
int requestContentLength = this.servletRequest.getContentLength();
|
||||
if (requestContentLength != -1) {
|
||||
this.headers.setContentLength(requestContentLength);
|
||||
|
||||
@@ -780,7 +780,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
if (!requestHeaders.isEmpty()) {
|
||||
httpHeaders.putAll(requestHeaders);
|
||||
}
|
||||
if (httpHeaders.getContentLength() == -1) {
|
||||
if (httpHeaders.getContentLength() < 0) {
|
||||
httpHeaders.setContentLength(0L);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user