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 单实例实现网站多域名请求

有时候写网站,为了统一的后端,把不同业务都集中到一个后端,这时就需要处理多域名的请求,在 Go http server 里实现很简单,只需把不同域名映射到不同的 `http.Handler`。...

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