11/*
2- * Copyright 2002-2016 the original author or authors.
2+ * Copyright 2002-2017 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.
@@ -96,7 +96,7 @@ protected AbstractHttpMessageConverter(Charset defaultCharset, MediaType... supp
9696 * Set the list of {@link MediaType} objects supported by this converter.
9797 */
9898 public void setSupportedMediaTypes (List <MediaType > supportedMediaTypes ) {
99- Assert .notEmpty (supportedMediaTypes , "'supportedMediaTypes' must not be empty" );
99+ Assert .notEmpty (supportedMediaTypes , "MediaType List must not be empty" );
100100 this .supportedMediaTypes = new ArrayList <>(supportedMediaTypes );
101101 }
102102
@@ -231,8 +231,8 @@ public HttpHeaders getHeaders() {
231231
232232 /**
233233 * Add default headers to the output message.
234- * <p>This implementation delegates to {@link #getDefaultContentType(Object)} if a content
235- * type was not provided, set if necessary the default character set, calls
234+ * <p>This implementation delegates to {@link #getDefaultContentType(Object)} if a
235+ * content type was not provided, set if necessary the default character set, calls
236236 * {@link #getContentLength}, and sets the corresponding headers.
237237 * @since 4.2
238238 */
@@ -256,7 +256,7 @@ else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) {
256256 headers .setContentType (contentTypeToUse );
257257 }
258258 }
259- if (headers .getContentLength () < 0 ) {
259+ if (headers .getContentLength () < 0 && ! headers . containsKey ( HttpHeaders . TRANSFER_ENCODING ) ) {
260260 Long contentLength = getContentLength (t , headers .getContentType ());
261261 if (contentLength != null ) {
262262 headers .setContentLength (contentLength );
0 commit comments