项目

一般

简介

访问应用模块报400错误httpheader请求头错误 :HTTP header行 [x-real-ip:61.142.73.7220x0d0x0aX-Forwarded-For: 61.142.73.72] 不符合RFC 7230并且已被忽略。

由 吕 鹏钦 在 超过 2 年 之前添加

问题描述:访问应用模块报Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: HTTP header行 [x-real-ip:61.142.73.7220x0d0x0aX-Forwarded-For: 61.142.73.72] 不符合RFC 7230并且已被忽略。

 

日志报错信息如下:

11-Apr-2022 10:33:10.876 信息 [http-exec-11] com.apusic.connector.http11.Http11Processor.service 解析 HTTP 请求 header 错误
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: HTTP header行 [x-real-ip:61.142.73.7220x0d0x0aX-Forwarded-For: 61.142.73.72] 不符合RFC 7230并且已被忽略。
  at com.apusic.connector.http11.Http11InputBuffer.skipLine(Http11InputBuffer.java:986)
  at com.apusic.connector.http11.Http11InputBuffer.parseHeader(Http11InputBuffer.java:905)
  at com.apusic.connector.http11.Http11InputBuffer.parseHeaders(Http11InputBuffer.java:565)
  at com.apusic.connector.http11.Http11Processor.service(Http11Processor.java:277)
  at com.apusic.connector.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
  at com.apusic.connector.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
  at com.apusic.aas.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1678)
  at com.apusic.aas.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at com.apusic.aas.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:748)

解决方法:新规范relaxedQueryChars="|{}[](),/:;<=>?@[\\]{}\\"
                       relaxedPathChars="|{}[](),/:;<=>?@[\\]{}\\"

在conf/apusic.conf中endpoint标签下加入  relaxedQueryChars="|{}[](),/:;<=>?@[\\]{}\\"    和   relaxedPathChars="|{}[](),/:;<=>?@[\\]{}\\"并重启