Fixed issue: NETTY-345 HttpChunkAggregator doesn't support retrieving trailing headers
* Merge the trailing headers into the aggregated message
This commit is contained in:
parent
ffccf71fa5
commit
d223c2905d
@ -16,6 +16,7 @@
|
|||||||
package org.jboss.netty.handler.codec.http;
|
package org.jboss.netty.handler.codec.http;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.jboss.netty.buffer.ChannelBuffer;
|
import org.jboss.netty.buffer.ChannelBuffer;
|
||||||
import org.jboss.netty.buffer.ChannelBuffers;
|
import org.jboss.netty.buffer.ChannelBuffers;
|
||||||
@ -118,9 +119,21 @@ public class HttpChunkAggregator extends SimpleChannelUpstreamHandler {
|
|||||||
content.writeBytes(chunk.getContent());
|
content.writeBytes(chunk.getContent());
|
||||||
if (chunk.isLast()) {
|
if (chunk.isLast()) {
|
||||||
this.currentMessage = null;
|
this.currentMessage = null;
|
||||||
|
|
||||||
|
// Merge trailing headers into the message.
|
||||||
|
if (chunk instanceof HttpChunkTrailer) {
|
||||||
|
HttpChunkTrailer trailer = (HttpChunkTrailer) chunk;
|
||||||
|
for (Entry<String, String> header: trailer.getHeaders()) {
|
||||||
|
currentMessage.setHeader(header.getKey(), header.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the 'Content-Length' header.
|
||||||
currentMessage.setHeader(
|
currentMessage.setHeader(
|
||||||
HttpHeaders.Names.CONTENT_LENGTH,
|
HttpHeaders.Names.CONTENT_LENGTH,
|
||||||
String.valueOf(content.readableBytes()));
|
String.valueOf(content.readableBytes()));
|
||||||
|
|
||||||
|
// All done - generate the event.
|
||||||
Channels.fireMessageReceived(ctx, currentMessage, e.getRemoteAddress());
|
Channels.fireMessageReceived(ctx, currentMessage, e.getRemoteAddress());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user