GolangNote

Golang笔记

golang fasthttp "body size exceeds the given limit" err

Permalink

在使用fasthttp 做图片服务时发现接口抛出这样一个错误。

首先检查nginx conf 的 client_body_buffer_sizeclient_max_body_size ,排出后再看fasthttp,原来fasthttp server 默认值 DefaultMaxRequestBodySize = 4 * 1024 * 1024,在主程序入口设置MaxRequestBodySize 即可。

Go: MaxRequestBodySize
1
2
3
4
5
s := &fasthttp.Server{
	Handler: router.Handler,
	MaxRequestBodySize: 100<<20, // 100MB
}
log.Fatal(s.ListenAndServe(":http"))

本文网址: https://golangnote.com/topic/213.html 转摘请注明来源

Related articles

Golang 实现 10 进制转 N 进制

给定一个不没有重复字符的字符串,如 `[0-9,a-z]`,把一个 10 进制数字转为,该字符集的字符串。应用场合如汽车牌、顺序计数。...

Write a Comment to "golang fasthttp "body size exceeds the given limit" err"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.20 Processed in 0ms