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 生成防识别的图片验证码

验证码 captcha 是对抗密码强力破解、垃圾信息的有效方式,一般用于用户注册、登录,当检测到频繁发帖时也会启用验证码。下面介绍用golang 生成防机器识别的图片验证码。...

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

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