Skip to content

Commit

Permalink
reverseproxy: fix parsing fails for unlimited request/response buffers
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Cox <[email protected]>
  • Loading branch information
mcfedr committed Sep 26, 2023
1 parent a306c5f commit 59026d7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
58 changes: 58 additions & 0 deletions caddytest/integration/caddyfile_adapt/reverse_proxy_buffers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
https://example.com {
reverse_proxy https://localhost:54321 {
request_buffers unlimited
response_buffers unlimited
}
}

----------
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"request_buffers": -1,
"response_buffers": -1,
"transport": {
"protocol": "http",
"tls": {}
},
"upstreams": [
{
"dial": "localhost:54321"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}
17 changes: 12 additions & 5 deletions modules/caddyhttp/reverseproxy/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,24 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if !d.NextArg() {
return d.ArgErr()
}
size, err := humanize.ParseBytes(d.Val())
if err != nil {
return d.Errf("invalid byte size '%s': %v", d.Val(), err)
val := d.Val()
var size int64
if val == "unlimited" {
size = -1
} else {
usize, err := humanize.ParseBytes(val)
if err != nil {
return d.Errf("invalid byte size '%s': %v", val, err)
}
size = int64(usize)
}
if d.NextArg() {
return d.ArgErr()
}
if subdir == "request_buffers" {
h.RequestBuffers = int64(size)
h.RequestBuffers = size
} else if subdir == "response_buffers" {
h.ResponseBuffers = int64(size)
h.ResponseBuffers = size
}

// TODO: These three properties are deprecated; remove them sometime after v2.6.4
Expand Down

0 comments on commit 59026d7

Please sign in to comment.