Merge pull request #526 from jamestyrrell/3
[#494] Automatically adding chunked encoding header breaks streaming
This commit is contained in:
commit
9ef39ac7cf
@ -118,6 +118,17 @@ final class HttpCodecUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void removeTransferEncodingChunked(HttpMessage m) {
|
||||
List<String> values = m.getHeaders(HttpHeaders.Names.TRANSFER_ENCODING);
|
||||
values.remove(HttpHeaders.Values.CHUNKED);
|
||||
m.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, values);
|
||||
}
|
||||
|
||||
static boolean isContentLengthSet(HttpMessage m) {
|
||||
List<String> contentLength = m.getHeaders(HttpHeaders.Names.CONTENT_LENGTH);
|
||||
return !contentLength.isEmpty();
|
||||
}
|
||||
|
||||
private HttpCodecUtil() {
|
||||
super();
|
||||
}
|
||||
|
@ -65,12 +65,18 @@ public abstract class HttpMessageEncoder extends OneToOneEncoder {
|
||||
HttpMessage m = (HttpMessage) msg;
|
||||
boolean chunked;
|
||||
if (m.isChunked()) {
|
||||
// check if the Transfer-Encoding is set to chunked already.
|
||||
// if not add the header to the message
|
||||
if (!HttpCodecUtil.isTransferEncodingChunked(m)) {
|
||||
m.addHeader(Names.TRANSFER_ENCODING, Values.CHUNKED);
|
||||
// if Content-Length is set then the message can't be HTTP chunked
|
||||
if (HttpCodecUtil.isContentLengthSet(m)) {
|
||||
chunked = this.chunked = false;
|
||||
HttpCodecUtil.removeTransferEncodingChunked(m);
|
||||
} else {
|
||||
// check if the Transfer-Encoding is set to chunked already.
|
||||
// if not add the header to the message
|
||||
if (!HttpCodecUtil.isTransferEncodingChunked(m)) {
|
||||
m.addHeader(Names.TRANSFER_ENCODING, Values.CHUNKED);
|
||||
}
|
||||
chunked = this.chunked = true;
|
||||
}
|
||||
chunked = this.chunked = true;
|
||||
} else {
|
||||
chunked = this.chunked = HttpCodecUtil.isTransferEncodingChunked(m);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user