异常日志信息
网上搜索的答案:
1、服务端提供的是HTTP接口,客户端使用HTTPS(没用过)
2、修改设置Tomcat中config路径下server.xml里的maxHttpHeaderSize值(亲测可用)
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
URIEncoding="UTF-8" redirectPort="8443" maxHttpHeaderSize="8192"/>
3、更改Tomcat版本(感觉没什么用)
4、前端修改<form>中有个method属性,设置为POST(不建议)
以下为源码位置tomcat-coyote.jar中对应的位置
public AbstractEndpoint.Handler.SocketState process(SocketWrapper<S> socketWrapper) throws IOException {
RequestInfo rp = this.request.getRequestProcessor();
rp.setStage(1);
setSocketWrapper(socketWrapper);
getInputBuffer().init(socketWrapper, this.endpoint);
getOutputBuffer().init(socketWrapper, this.endpoint);
this.keepAlive = true;
this.comet = false;
this.openSocket = false;
this.sendfileInProgress = false;
this.readComplete = true;
if (this.endpoint.getUsePolling())
this.keptAlive = false;
else {
this.keptAlive = socketWrapper.isKeptAlive();
}
if (disableKeepAlive()) {
socketWrapper.setKeepAliveLeft(0);
}
while ((!getErrorState().isError()) && (this.keepAlive) && (!this.comet) && (!isAsync()) && (this.upgradeToken == null) && (!this.endpoint.isPaused()))
{
try
{
setRequestLineReadTimeout();
if ((!getInputBuffer().parseRequestLine(this.keptAlive)) &&
(handleIncompleteRequestLineRead()))
{
break;
}
if (this.endpoint.isPaused())
{
this.response.setStatus(503);
setErrorState(ErrorState.CLOSE_CLEAN, null);
} else {
this.keptAlive = true;
this.request.getMimeHeaders().setLimit(this.endpoint.getMaxHeaderCount());
this.request.getCookies().setLimit(getMaxCookieCount());
if (!getInputBuffer().parseHeaders())
{
this.openSocket = true;
this.readComplete = false;
break;
}
if (!this.disableUploadTimeout)
setSocketTimeout(this.connectionUploadTimeout);
}
}
catch (IOException e) {
if (getLog().isDebugEnabled()) {
getLog().debug(sm.getString("http11processor.header.parse"), e);
}
setErrorState(ErrorState.CLOSE_NOW, e);
break;
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
UserDataHelper.Mode logMode = this.userDataHelper.getNextMode();
if (logMode != null) {
String message = sm.getString("http11processor.header.parse");
switch (1.$SwitchMap$org$apache$tomcat$util$log$UserDataHelper$Mode[logMode.ordinal()]) {
case 1:
message = message + sm.getString("http11processor.fallToDebug");
case 2:
getLog().info(message, t);
break;
case 3:
getLog().debug(message, t);
}
}
this.response.setStatus(400);
setErrorState(ErrorState.CLOSE_CLEAN, t);
getAdapter().log(this.request, this.response, 0L);
}
if (!getErrorState().isError())
{
rp.setStage(2);
try {
prepareRequest();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
if (getLog().isDebugEnabled()) {
getLog().debug(sm.getString("http11processor.request.prepare"), t);
}
this.response.setStatus(500);
setErrorState(ErrorState.CLOSE_CLEAN, t);
getAdapter().log(this.request, this.response, 0L);
}
}
if (this.maxKeepAliveRequests == 1)
this.keepAlive = false;
else if ((this.maxKeepAliveRequests > 0) && (socketWrapper.decrementKeepAlive() <= 0))
{
this.keepAlive = false;
}
if (!getErrorState().isError()) {
try {
rp.setStage(3);
getAdapter().service(this.request, this.response);
if ((this.keepAlive) && (!getErrorState().isError()) && (!isAsync()) && (statusDropsConnection(this.response.getStatus())))
{
setErrorState(ErrorState.CLOSE_CLEAN, null);
}
setCometTimeouts(socketWrapper);
} catch (InterruptedIOException e) {
setErrorState(ErrorState.CLOSE_NOW, e);
} catch (HeadersTooLargeException e) {
getLog().error(sm.getString("http11processor.request.process"), e);
if (this.response.isCommitted()) {
setErrorState(ErrorState.CLOSE_NOW, e);
} else {
this.response.reset();
this.response.setStatus(500);
setErrorState(ErrorState.CLOSE_CLEAN, e);
this.response.setHeader("Connection", "close");
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
getLog().error(sm.getString("http11processor.request.process"), t);
this.response.setStatus(500);
setErrorState(ErrorState.CLOSE_CLEAN, t);
getAdapter().log(this.request, this.response, 0L);
}
}
rp.setStage(4);
if ((!isAsync()) && (!this.comet)) {
if (getErrorState().isError())
{
getInputBuffer().setSwallowInput(false);
}
else
{
checkExpectationAndResponseStatus();
}
endRequest();
}
rp.setStage(5);
if (getErrorState().isError()) {
this.response.setStatus(500);
}
if (((!isAsync()) && (!this.comet)) || (getErrorState().isError())) {
this.request.updateCounters();
if (getErrorState().isIoAllowed()) {
getInputBuffer().nextRequest();
getOutputBuffer().nextRequest();
}
}
if (!this.disableUploadTimeout) {
if (this.endpoint.getSoTimeout() > 0)
setSocketTimeout(this.endpoint.getSoTimeout());
else {
setSocketTimeout(0);
}
}
rp.setStage(6);
if (breakKeepAliveLoop(socketWrapper)) {
break;
}
}
rp.setStage(7);
if ((getErrorState().isError()) || (this.endpoint.isPaused()))
return AbstractEndpoint.Handler.SocketState.CLOSED;
if ((isAsync()) || (this.comet))
return AbstractEndpoint.Handler.SocketState.LONG;
if (isUpgrade()) {
return AbstractEndpoint.Handler.SocketState.UPGRADING;
}
if (this.sendfileInProgress) {
return AbstractEndpoint.Handler.SocketState.SENDFILE;
}
if (this.openSocket) {
if (this.readComplete) {
return AbstractEndpoint.Handler.SocketState.OPEN;
}
return AbstractEndpoint.Handler.SocketState.LONG;
}
return AbstractEndpoint.Handler.SocketState.CLOSED;
}
报错位置为:
if (!getInputBuffer().parseHeaders())//这里
{
this.openSocket = true;
this.readComplete = false;
break;
}
if (!this.disableUploadTimeout)
setSocketTimeout(this.connectionUploadTimeout);
}
}
catch (IOException e) {
if (getLog().isDebugEnabled()) {
getLog().debug(sm.getString("http11processor.header.parse"), e);
}
setErrorState(ErrorState.CLOSE_NOW, e);
break;
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
UserDataHelper.Mode logMode = this.userDataHelper.getNextMode();
if (logMode != null) {
String message = sm.getString("http11processor.header.parse");
switch (1.$SwitchMap$org$apache$tomcat$util$log$UserDataHelper$Mode[logMode.ordinal()]) {
case 1:
message = message + sm.getString("http11processor.fallToDebug");//处理异常
case 2:
getLog().info(message, t);
break;
case 3:
getLog().debug(message, t);
}
}