Skip to content

Commit 8ca031b

Browse files
committed
chore: increase max request body size
1 parent b5ad227 commit 8ca031b

5 files changed

Lines changed: 41 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.5.1] - 2026-02-20
9+
### Changed
10+
- Increased default maximum request body size to 16MB
11+
812
## [0.5.0] - 2026-02-11
913

1014
### Added

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0
1+
0.5.1

internal/pureproxy/pureproxy.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func forwardAndRespond(ps *ProxyServer, ctx *fasthttp.RequestCtx) {
8989

9090
func RunProxy() {
9191
port := common.GetPort()
92+
const maxRequestBodySize = 16 * 1024 * 1024
9293

9394
upstream := os.Getenv("PROXY_HOST")
9495
if upstream == "" {
@@ -113,10 +114,18 @@ func RunProxy() {
113114
fmt.Printf("| Port: %-69d|\n", port)
114115
fmt.Printf("| Upstream: %-66s|\n", upstream)
115116
fmt.Printf("| Verbose: %-66v|\n", verbose)
117+
fmt.Printf("| Max Request Body: %-57s|\n", fmt.Sprintf("%d bytes", maxRequestBodySize))
116118
fmt.Println("| |")
117119
fmt.Println("└──────────────────────────────────────────────────────────────────────────────┘")
118120

119-
log.Fatal(fasthttp.ListenAndServe(addr, func(ctx *fasthttp.RequestCtx) {
120-
handleProxyRequest(ps, ctx)
121-
}))
121+
httpServer := &fasthttp.Server{
122+
Handler: func(ctx *fasthttp.RequestCtx) { handleProxyRequest(ps, ctx) },
123+
MaxRequestBodySize: maxRequestBodySize,
124+
ErrorHandler: func(ctx *fasthttp.RequestCtx, err error) {
125+
ctx.SetStatusCode(fasthttp.StatusBadRequest)
126+
ctx.SetBodyString(err.Error())
127+
},
128+
}
129+
130+
log.Fatal(httpServer.ListenAndServe(addr))
122131
}

internal/record/record.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ func compileURLMatcher(pattern string) func(string) bool {
610610

611611
func RunRecord() {
612612
port := common.GetPort()
613+
const maxRequestBodySize = 16 * 1024 * 1024
613614

614615
upstream := os.Getenv("PROXY_HOST")
615616
if upstream == "" {
@@ -637,10 +638,18 @@ func RunRecord() {
637638
fmt.Printf("| Port: %-69d|\n", port)
638639
fmt.Printf("| Upstream: %-66s|\n", upstream)
639640
fmt.Printf("| Verbose: %-66v|\n", verbose)
641+
fmt.Printf("| Max Request Body: %-57s|\n", fmt.Sprintf("%d bytes", maxRequestBodySize))
640642
fmt.Println("| |")
641643
fmt.Println("└──────────────────────────────────────────────────────────────────────────────┘")
642644

643-
log.Fatal(fasthttp.ListenAndServe(addr, func(ctx *fasthttp.RequestCtx) {
644-
handleRecordRequest(rs, ctx)
645-
}))
645+
httpServer := &fasthttp.Server{
646+
Handler: func(ctx *fasthttp.RequestCtx) { handleRecordRequest(rs, ctx) },
647+
MaxRequestBodySize: maxRequestBodySize,
648+
ErrorHandler: func(ctx *fasthttp.RequestCtx, err error) {
649+
ctx.SetStatusCode(fasthttp.StatusBadRequest)
650+
ctx.SetBodyString(err.Error())
651+
},
652+
}
653+
654+
log.Fatal(httpServer.ListenAndServe(addr))
646655
}

main.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func main() {
3838

3939
func runReplay() {
4040
port := common.GetPort()
41+
const maxRequestBodySize = 16 * 1024 * 1024
4142

4243
proxyHost := os.Getenv("PROXY_HOST")
4344
if proxyHost == "" {
@@ -90,10 +91,18 @@ func runReplay() {
9091
fmt.Printf("| Mode: %-69s|\n", "replay")
9192
fmt.Printf("| Port: %-69d|\n", port)
9293
fmt.Printf("| Verbose: %-66v|\n", verbose)
94+
fmt.Printf("| Max Request Body: %-57s|\n", fmt.Sprintf("%d bytes", maxRequestBodySize))
9395
fmt.Println("| |")
9496
fmt.Println("└──────────────────────────────────────────────────────────────────────────────┘")
9597

96-
log.Fatal(fasthttp.ListenAndServe(addr, func(ctx *fasthttp.RequestCtx) {
97-
server.HandleRequest(s, ctx)
98-
}))
98+
httpServer := &fasthttp.Server{
99+
Handler: func(ctx *fasthttp.RequestCtx) { server.HandleRequest(s, ctx) },
100+
MaxRequestBodySize: maxRequestBodySize,
101+
ErrorHandler: func(ctx *fasthttp.RequestCtx, err error) {
102+
ctx.SetStatusCode(fasthttp.StatusBadRequest)
103+
ctx.SetBodyString(err.Error())
104+
},
105+
}
106+
107+
log.Fatal(httpServer.ListenAndServe(addr))
99108
}

0 commit comments

Comments
 (0)