GET请求 413 Request Entity Too Large

问题原因:URL超长请求,超出解码长度

进入网关后报错,如下图An HTTP line is larger than 4096 bytes.

io.netty.handler.codec.http.TooLongHttpLineException: An HTTP line is larger than 4096 bytes.
	at io.netty.handler.codec.http.HttpObjectDecoder$LineParser.newException(HttpObjectDecoder.java:1016)
	at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.increaseCount(HttpObjectDecoder.java:979)
	at io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.process(HttpObjectDecoder.java:967)
	at io.netty.handler.codec.http.HttpObjectDecoder$LineParser.process(HttpObjectDecoder.java:1011)

具体报错位置,是否报错由maxLength来决定的,maxLength初始化值4096

 

 

解决方案

我们可以在外部设置maxInitialLineLength的长度来改变这个值

在项目application.yml页面添加netty的,不要加成httpclient

server:
  netty:
    max-initial-line-length: 100000


 

另:nginx拦截413情况处理方式

需要修改配置nginx.conf

请求body超过默认大小,需要根据你请求体的大小设置client_max_body_size 

在http:{...}中添加

client_max_body_size 10m;

配置好后重启即可。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值