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 实现的基于web的文件管理-filebrowser

FileBrowser 在指定目录中提供了一个文件管理界面,可用于上传,删除,预览,重命名和编辑文件。它允许创建多个用户,每个用户都可以有自己的目录。它可以用作独立的应用程序。...

Golang 数据库 Bolt 碎片整理

Bolt 是一个优秀、纯 Go 实现、支持 ACID 事务的嵌入式 Key/Value 数据库。但在使用过程中会有很多空间碎片。一般数据库占用的空间是元数据空间的 1.5~4 倍。Bolt 没有内置的压缩功能,需要手动压缩。...

Golang Range 的性能提升Tip

Go 语言里使用 range 可以方便遍历数组(array)、切片(slice)、字典(map)和信道(chan)。这里主要关注他们的性能。...

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