我在karaf Jetty上运行REST API,REST服务使用JWT令牌来提高安全性。当向服务发送请求时,服务器抱怨标头很大。抛出以下异常(标题太大> 8192)。
2017-04-28 10:38:35,461 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | URI --> SPACE2
2017-04-28 10:38:35,461 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | SPACE2 --> REQUEST_VERSION
2017-04-28 10:38:35,461 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | REQUEST_VERSION --> HEADER
2017-04-28 10:38:35,461 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | HEADER --> HEADER_VALUE
2017-04-28 10:38:35,461 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | HEADER_VALUE --> HEADER_IN_VALUE
2017-04-28 10:38:35,464 | DEBUG | tp1430443284-800 | ChannelEndPoint | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | filled 1887 SelectChannelEndPoint@269ccd27{/10.30.8.29:14179<->8181,Open,in,out,-,-,4/30000,HttpConnection}{io=0,kio=0,kro=1}
2017-04-28 10:38:35,464 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | parseNext s=HEADER_IN_VALUE HeapByteBuffer@77e9f1ca[p=0,l=1887,c=8192,r=1887]={<<<NSVhfTU5HUl9HRVRf...0.8.29:8181\r\n\r\n>>>JPTEVfVk1XQVJFX01...T0xFX1NFUlZJQ0V}
2017-04-28 10:38:35,464 | WARN | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | Header is too large >8192
2017-04-28 10:38:35,465 | WARN | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | badMessage: 413 for HttpChannelOverHttp@548aa950{r=0,c=false,a=IDLE,uri=-}
2017-04-28 10:38:35,465 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 |
org.eclipse.jetty.http.HttpParser$BadMessageException
at org.eclipse.jetty.http.HttpParser.parseHeaders(HttpParser.java:932)[97:org.eclipse.jetty.http:9.2.10.v20150310]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1256)[97:org.eclipse.jetty.http:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:250)[106:org.eclipse.jetty.server:9.2.10.v20150310]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)[98:org.eclipse.jetty.io:9.2.10.v20150310]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[109:org.eclipse.jetty.util:9.2.10.v20150310]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[109:org.eclipse.jetty.util:9.2.10.v20150310]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_101]
2017-04-28 10:38:35,465 | DEBUG | tp1430443284-800 | HttpParser | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | HEADER_IN_VALUE --> CLOSED
2017-04-28 10:38:35,465 | DEBUG | tp1430443284-800 | HttpChannelState | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | HttpChannelState@462fabb8{s=IDLE i=true a=null} handling IDLE
2017-04-28 10:38:35,465 | DEBUG | tp1430443284-800 | HttpConnection | 109 - org.eclipse.jetty.util - 9.2.10.v20150310 | org.eclipse.jetty.server.HttpConnect
我尝试使用jetty.xml上的以下配置增加JETTY的头大小属性。然而,jetty一直抱怨标题大小(标题太大&gt; 8192),更改后会出现相同的异常。由于某种原因,JETTY没有使用此配置增加标头大小,有人可以解释如何解决这个问题吗?感谢
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">
<Property name="jetty.host" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8181" />
</Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
<Set name="requestHeaderSize">32768</Set>
<Set name="headerCacheSize">32768</Set>
</New>
</Arg>
</Call>
经过一番研究后,我发现一条帖子指向jetty.xml上的以下配置更改,这是使用SSL但是在jetty中标题大小仍然没有变化,我得到同样的错误。
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme">https</Set>
<Set name="securePort">
<Property name="jetty.secure.port" default="8443" />
</Set>
<Set name="outputBufferSize">32768</Set>
<Set name="requestHeaderSize">32768</Set>
<Set name="responseHeaderSize">32768</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">false</Set>
<Set name="headerCacheSize">512</Set>
</New>
答案 0 :(得分:0)
经过多天的研究,我找到了一个解决方案,我在以下网址找到了解决方案
https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/security_guide/webconsole
此解决方案会增加请求标头的大小,但会使用HTTPS。