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 phantomjs 动态代理实现

phantomjs 是个很优秀的软件,虽然现在被chrome headless 抢了风头,但在某些特定场合,使用phantomjs 还是很方便,这里是介绍使用Go 实现动态代理。...

Golang 数据库 Bolt 碎片整理

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

Golang 把cookie 字符串解析为cookie 结构

在做爬虫时有时候会遇到需要带已登录的 cookie 请求,这个时候最简单的方法是在浏览器登录后,在开发者面板找到cookie 字符串,然后拷贝粘贴。这就面临一个问题需要把cookie 字符串解析成Go 语言 cookie 结构体。...

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