Skip to content

Commit

Permalink
Skip default Content-Length if Transfer-Encoding header has been set
Browse files Browse the repository at this point in the history
Issue: SPR-15212
  • Loading branch information
jhoeller committed Feb 2, 2017
1 parent e44533f commit 9b3131f
Showing 1 changed file with 5 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
Expand Down Expand Up @@ -96,7 +96,7 @@ protected AbstractHttpMessageConverter(Charset defaultCharset, MediaType... supp
* Set the list of {@link MediaType} objects supported by this converter.
*/
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' must not be empty");
Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty");
this.supportedMediaTypes = new ArrayList<>(supportedMediaTypes);
}

Expand Down Expand Up @@ -231,8 +231,8 @@ public HttpHeaders getHeaders() {

/**
* Add default headers to the output message.
* <p>This implementation delegates to {@link #getDefaultContentType(Object)} if a content
* type was not provided, set if necessary the default character set, calls
* <p>This implementation delegates to {@link #getDefaultContentType(Object)} if a
* content type was not provided, set if necessary the default character set, calls
* {@link #getContentLength}, and sets the corresponding headers.
* @since 4.2
*/
Expand All @@ -256,7 +256,7 @@ else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) {
headers.setContentType(contentTypeToUse);
}
}
if (headers.getContentLength() < 0) {
if (headers.getContentLength() < 0 && !headers.containsKey(HttpHeaders.TRANSFER_ENCODING)) {
Long contentLength = getContentLength(t, headers.getContentType());
if (contentLength != null) {
headers.setContentLength(contentLength);
Expand Down

0 comments on commit 9b3131f

Please sign in to comment.