From dc97af318522a57f5ff95148c2e287710a7017c9 Mon Sep 17 00:00:00 2001 From: Brock Noland Date: Fri, 30 Dec 2016 14:22:35 -0600 Subject: [PATCH] Provide Jetty Http Request/Response Header Size Configuration Kerberos over http requires larger header sizes than the default, or the HTTP Error 413 Request entity too large will be returned. This patch increases the default for Livy to 128K and also allows this to be configurable. --- server/src/main/scala/com/cloudera/livy/LivyConf.scala | 2 ++ .../scala/com/cloudera/livy/server/WebServer.scala | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/src/main/scala/com/cloudera/livy/LivyConf.scala b/server/src/main/scala/com/cloudera/livy/LivyConf.scala index f00c17e8e..2d41da391 100644 --- a/server/src/main/scala/com/cloudera/livy/LivyConf.scala +++ b/server/src/main/scala/com/cloudera/livy/LivyConf.scala @@ -58,6 +58,8 @@ object LivyConf { val SERVER_HOST = Entry("livy.server.host", "0.0.0.0") val SERVER_PORT = Entry("livy.server.port", 8998) + val HTTP_REQUEST_HEADER_SIZE = Entry("livy.http.request.header.size", 131072) + val HTTP_RESPONSE_HEADER_SIZE = Entry("livy.http.response.header.size", 131072) val CSRF_PROTECTION = LivyConf.Entry("livy.server.csrf_protection.enabled", false) val IMPERSONATION_ENABLED = Entry("livy.impersonation.enabled", false) diff --git a/server/src/main/scala/com/cloudera/livy/server/WebServer.scala b/server/src/main/scala/com/cloudera/livy/server/WebServer.scala index a07b05fec..ee517f0bc 100644 --- a/server/src/main/scala/com/cloudera/livy/server/WebServer.scala +++ b/server/src/main/scala/com/cloudera/livy/server/WebServer.scala @@ -39,12 +39,20 @@ class WebServer(livyConf: LivyConf, var host: String, var port: Int) extends Log server.setStopTimeout(1000) server.setStopAtShutdown(true) + val requestHeaderSize = livyConf.getInt(LivyConf.HTTP_REQUEST_HEADER_SIZE) + val responseHeaderSize = livyConf.getInt(LivyConf.HTTP_RESPONSE_HEADER_SIZE) + val (connector, protocol) = Option(livyConf.get(WebServer.KeystoreKey)) match { case None => - (new ServerConnector(server), "http") + val http = new HttpConfiguration() + http.setRequestHeaderSize(requestHeaderSize) + http.setResponseHeaderSize(responseHeaderSize) + (new ServerConnector(server, new HttpConnectionFactory(http)), "http") case Some(keystore) => val https = new HttpConfiguration() + https.setRequestHeaderSize(requestHeaderSize) + https.setResponseHeaderSize(responseHeaderSize) https.addCustomizer(new SecureRequestCustomizer()) val sslContextFactory = new SslContextFactory()