Jetty HTTP 413 Header Full Error - Java / Scala

I am using Jetty 7.6 with a Scalatra web map. In some requests I need to send a large text as the response body to the client, I use HttpServletResponse.getWriter () to record the response.

I noticed that on the client side I am getting 413 Header Full error. Apparently, one solution to this problem in Jetty is to increase the size of the ship's header buffer.

I would like to know that HttpServletResponse.getWriter () is related to the size of the request header ?! As I understand it, HttpServletResponse.getWriter () writes to the response body, not the response header.

I appreciate if anyone can explain this problem.

+5
source share
3 answers

, , (, joakime yougth). Jetty .

  • ( HTTP-) , .
  • , .
  • , Http 413.

(), , , Http "chunked".

.

, . : http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/nio/SelectChannelConnector.html

http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/nio/AbstractNIOConnector.html

http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/AbstractConnector.html#setRequestHeaderSize(int)

jetty.xml :

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"     "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
 <Call name="addConnector">
  <Arg>
   <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
    <Set name="requestHeaderSize">8192</Set>
   </New>
  </Arg>
 </Call>
</Configure>
+6

HTTP- 413 - HttpStatus. REQUEST_ENTITY_TOO_LARGE.

HttpServletResponse.getWriter().

, .

+3

Jetty 9, SelectChannelConnector. jetty.xml -

<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
  <Set name="requestHeaderSize">8192</Set>      
</New> 

<Call name="addConnector">
  <Arg>
    <New class="org.eclipse.jetty.server.ServerConnector">
      <Arg name="server"><Ref id="Server" /></Arg>
      <Arg name="factories">
        <Array type="org.eclipse.jetty.server.ConnectionFactory">
          <Item>
            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
              <Arg name="config"><Ref id="httpConfig" /></Arg>
            </New>
          </Item>
        </Array>
      </Arg>
      <Set name="port">8080</Set>
    </New>
  </Arg>
</Call>

. http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html

+2

All Articles