<p dir="auto"><strong>Elasticsearch version</strong>: 5.0.0-alpha5<br>
<strong>Plugins installed</strong>: []</p>
<p dir="auto"><strong>JVM version</strong>: openjdk version "1.8.0_91"</p>
<p dir="auto"><strong>OS version</strong>: Linux 4.4.0-28-generic <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="142524" data-permission-text="Title is private" data-url="https://github.com/elastic/elasticsearch/issues/47" data-hovercard-type="issue" data-hovercard-url="/elastic/elasticsearch/issues/47/hovercard" href="https://github.com/elastic/elasticsearch/issues/47">#47</a>-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:<br>
when trying to load template with command:<br>
<code class="notranslate">curl -v -XPUT http://localhost:9200/_template/template_esb -d @/path/to/template_esb.json</code></p>
<p dir="auto">I got empty response from server in case template file &gt;1024 bytes.<br>
In ES I got:<br>
<code class="notranslate">[2016-08-11 14:19:10,657][WARN ][http.netty4              ] [7o-5HeP] caught exception while handling client http traffic, closing connection [id: 0x83358c12, L:/127.0.0.1:9200 - R:/127.0.0.1:39434] java.lang.UnsupportedOperationException: unsupported message type: DefaultFullHttpResponse (expected: ByteBuf, FileRegion)</code></p>
<p dir="auto">If I cut file to be less than 1024 bytes then template created successfully.<br>
The same template works fine in 5.0.0-alpha1</p>
<p dir="auto"><strong>Steps to reproduce</strong>:</p>
<ol dir="auto">
<li>start ES</li>
<li>prepare template file with size &gt;1024 bytes</li>
<li>curl -XPUT <a href="http://localhost:9200/_template/template_esb" rel="nofollow">http://localhost:9200/_template/template_esb</a> -d @/path/to/template_esb.json</li>
</ol>
<p dir="auto"><strong>Provide logs (if relevant)</strong>:<br>
<code class="notranslate">[2016-08-11 14:19:10,657][WARN ][http.netty4              ] [7o-5HeP] caught exception while handling client http traffic, closing connection [id: 0x83358c12, L:/127.0.0.1:9200 - R:/127.0.0.1:39434] java.lang.UnsupportedOperationException: unsupported message type: DefaultFullHttpResponse (expected: ByteBuf, FileRegion) at io.netty.channel.nio.AbstractNioByteChannel.filterOutboundMessage(AbstractNioByteChannel.java:260) at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:799) at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1291) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:748) at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:811) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:824) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:804) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:841) at io.netty.handler.codec.MessageAggregator.decode(MessageAggregator.java:222) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350) at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:571) at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:474) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:428) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:398) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877) at java.lang.Thread.run(Thread.java:745)</code></p>

<p dir="auto"><strong>Describe the feature</strong>:</p>
<p dir="auto">When using Netty4 HTTP transport type I have the following issue:</p>
<h4 dir="auto">Netty4</h4>
<p dir="auto">Starting master using  <code class="notranslate">http.type: netty4</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bin/elasticsearch --E http.type=netty4"><pre class="notranslate"><code class="notranslate">bin/elasticsearch --E http.type=netty4
</code></pre></div>
<p dir="auto">Creating a document with a medium size JSON document using cUrl (sample document is <a href="https://gist.github.com/tlrx/5df7b9fe79e076b98c731e07d877650d">here</a>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -v -XPOST 'localhost:9200/samples/sample/0' -d '{
   &quot;title&quot;:&quot;My awesome book&quot;,
   &quot;pages&quot;:456,
   &quot;price&quot;:27.99,
   &quot;timestamp&quot;:1428582942867,
    ..... 30 other fields...
}'"><pre class="notranslate"><code class="notranslate">curl -v -XPOST 'localhost:9200/samples/sample/0' -d '{
   "title":"My awesome book",
   "pages":456,
   "price":27.99,
   "timestamp":1428582942867,
    ..... 30 other fields...
}'
</code></pre></div>
<p dir="auto">Here is the curl output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
&gt; POST /samples/sample/0 HTTP/1.1
&gt; Host: localhost:9200
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; Content-Length: 1681
&gt; Content-Type: application/x-www-form-urlencoded
&gt; Expect: 100-continue
&gt; 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server"><pre class="notranslate"><code class="notranslate">
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
&gt; POST /samples/sample/0 HTTP/1.1
&gt; Host: localhost:9200
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; Content-Length: 1681
&gt; Content-Type: application/x-www-form-urlencoded
&gt; Expect: 100-continue
&gt; 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
</code></pre></div>
<p dir="auto">And the elasticsearch logs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
[2016-08-05 17:46:13,354][WARN ][http.netty4              ] [UqG1hcq] caught exception while handling client http traffic, closing connection [id: 0x0ca9a8ca, L:/127.0.0.1:9200 - R:/127.0.0.1:43208]
java.lang.UnsupportedOperationException: unsupported message type: DefaultFullHttpResponse (expected: ByteBuf, FileRegion)
    at io.netty.channel.nio.AbstractNioByteChannel.filterOutboundMessage(AbstractNioByteChannel.java:260)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:799)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1291)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:748)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:811)
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:824)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:804)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:841)
    at io.netty.handler.codec.MessageAggregator.decode(MessageAggregator.java:222)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:571)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:474)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:428)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:398)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877)
    at java.lang.Thread.run(Thread.java:745)"><pre class="notranslate"><code class="notranslate">
[2016-08-05 17:46:13,354][WARN ][http.netty4              ] [UqG1hcq] caught exception while handling client http traffic, closing connection [id: 0x0ca9a8ca, L:/127.0.0.1:9200 - R:/127.0.0.1:43208]
java.lang.UnsupportedOperationException: unsupported message type: DefaultFullHttpResponse (expected: ByteBuf, FileRegion)
    at io.netty.channel.nio.AbstractNioByteChannel.filterOutboundMessage(AbstractNioByteChannel.java:260)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:799)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1291)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:748)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:811)
    at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:824)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:804)
    at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:841)
    at io.netty.handler.codec.MessageAggregator.decode(MessageAggregator.java:222)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:350)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:358)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:571)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:474)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:428)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:398)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:877)
    at java.lang.Thread.run(Thread.java:745)
</code></pre></div>
<p dir="auto">Update: as a workaround for users, forcing the <code class="notranslate">Expect</code> header to empty makes the request succeed:</p>
<p dir="auto"><code class="notranslate">curl -v -H "Expect:" -XPOST 'localhost:9200/samples/sample/0' -d '...'</code></p>
<h4 dir="auto">Netty3</h4>
<p dir="auto">It works fine with  <code class="notranslate">http.type: netty3</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bin/elasticsearch --E http.type=netty3"><pre class="notranslate"><code class="notranslate">bin/elasticsearch --E http.type=netty3
</code></pre></div>
<p dir="auto">Creating the document:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="curl -v -XPOST 'localhost:9200/samples/sample/0' -d '{
   &quot;title&quot;:&quot;My awesome book&quot;,
   &quot;pages&quot;:456,
   &quot;price&quot;:27.99,
   &quot;timestamp&quot;:1428582942867,
    ..... 30 other fields...
}'"><pre class="notranslate"><code class="notranslate">curl -v -XPOST 'localhost:9200/samples/sample/0' -d '{
   "title":"My awesome book",
   "pages":456,
   "price":27.99,
   "timestamp":1428582942867,
    ..... 30 other fields...
}'
</code></pre></div>
<p dir="auto">Here is the curl output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
&gt; POST /samples/sample/0 HTTP/1.1
&gt; Host: localhost:9200
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; Content-Length: 1681
&gt; Content-Type: application/x-www-form-urlencoded
&gt; Expect: 100-continue
&gt; 
&lt; HTTP/1.1 100 Continue
* We are completely uploaded and fine
&lt; HTTP/1.1 201 Created
&lt; Location: /samples/sample/0
&lt; Content-Type: application/json; charset=UTF-8
&lt; Content-Length: 142
&lt; 
* Connection #0 to host localhost left intact
{&quot;_index&quot;:&quot;samples&quot;,&quot;_type&quot;:&quot;sample&quot;,&quot;_id&quot;:&quot;0&quot;,&quot;_version&quot;:1,&quot;result&quot;:&quot;created&quot;,&quot;_shards&quot;:{&quot;total&quot;:2,&quot;successful&quot;:1,&quot;failed&quot;:0},&quot;created&quot;:true}%   
"><pre class="notranslate"><code class="notranslate">
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9200 (#0)
&gt; POST /samples/sample/0 HTTP/1.1
&gt; Host: localhost:9200
&gt; User-Agent: curl/7.47.0
&gt; Accept: */*
&gt; Content-Length: 1681
&gt; Content-Type: application/x-www-form-urlencoded
&gt; Expect: 100-continue
&gt; 
&lt; HTTP/1.1 100 Continue
* We are completely uploaded and fine
&lt; HTTP/1.1 201 Created
&lt; Location: /samples/sample/0
&lt; Content-Type: application/json; charset=UTF-8
&lt; Content-Length: 142
&lt; 
* Connection #0 to host localhost left intact
{"_index":"samples","_type":"sample","_id":"0","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}%   

</code></pre></div>