Netty TooLongFrameException: How is the length computed?
<p>I have a test server and a client application. Server is built with <code>Vert.x 3.2.1</code> (users Netty 4.0.33.Final) and client with <code>Apache httpclient 4.5.1</code>.</p>

<p>Have configured server to accept <code>maxHeaderSize</code> as 8KB. As I send requests from client I see that requests bearing header sizes of around 3KB starts failing with below exception on server.</p>

<blockquote>
  <p>io.netty.handler.codec.TooLongFrameException: HTTP header is larger than 8192 bytes</p>
</blockquote>

<p>Sharing the server and client code for reference.</p>

<p><strong>Server:</strong></p>

<pre><code>    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        HttpServerOptions options = new HttpServerOptions();
        options.setMaxHeaderSize(1024*8);
        HttpServer httpServer = (HttpServer) vertx.createHttpServer(options );
        httpServer.requestHandler(req -&gt; {
            System.out.println(req.headers().names());
            for(String h : req.headers().names()){
                System.out.println(h+": "+req.headers().get(h).length()+": "+(h.length()+req.headers().get(h).length()));
            }
            req.response().setStatusCode(200).end();
        });
        httpServer.listen(6565);

    }
</code></pre>

<p><strong>Client:</strong></p>

<pre><code>public static void main(String[] args) {

    try {
        CloseableHttpClient httpclient = HttpClients.custom().build();
        HttpGet get = new HttpGet("http://localhost:6565");
        String headerValue = generateHeader(3045);
        get.addHeader("myheader", headerValue);
        HttpResponse response = httpclient.execute(get);
        String resp = IOUtils.toString(response.getEntity().getContent());
        System.out.println(response.getStatusLine());
        httpclient.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
</code></pre>

<p><code>generateHeader()</code> is a method that generates a String of specified length - when input with 3, result is "aaa".</p>

<p>Apache http client also adds some more headers - Host, Connection, User-Agent and Accept-Encoding. Along with all these, The behavior I notice is that the server fails when I pass 3045 or above as input to <code>generateHeader()</code>, but succeeds for any lower value.</p>

<p>Though configured is 8k, I fail to understand why failures occur for such lower values.</p>