Skip to content

Make request header read buffer size configurable (fixes 431 Request Header Fields Too Large) - #173

Open
neverlless wants to merge 1 commit into
ubccr:mainfrom
neverlless:feat/configurable-read-buffer-size
Open

Make request header read buffer size configurable (fixes 431 Request Header Fields Too Large)#173
neverlless wants to merge 1 commit into
ubccr:mainfrom
neverlless:feat/configurable-read-buffer-size

Conversation

@neverlless

@neverlless neverlless commented Jul 21, 2026

Copy link
Copy Markdown

Problem

Fiber's default ReadBufferSize is 4096 bytes, so mokey rejects any request whose headers exceed 4KB with 431 Request Header Fields Too Large:

level=error msg="Request Header Fields Too Large" code=431 path=/ username="<nil>"

This happens easily when mokey runs on a (sub)domain shared with other applications that set large cookies, or behind auth proxies that add sizable headers. Reported in #122.

Fix

  • Add a server.read_buffer_size config option wired to fiber.Config.ReadBufferSize, defaulting to 16384.
  • Document the option in mokey.toml.sample.

Testing

Deployed in production behind Traefik where users' shared-domain cookies previously triggered 431s. Verified in the running container:

# before (v1.0.2 base): 5KB cookie
curl -H "Cookie: junk=<5KB>" http://localhost:8866/   -> 431
# after: 5KB and 12KB cookies
curl -H "Cookie: junk=<5KB>" http://localhost:8866/   -> 302
curl -H "Cookie: junk=<12KB>" http://localhost:8866/  -> 302

Fixes #122

Fiber's default ReadBufferSize of 4096 bytes causes mokey to reject
requests with 431 Request Header Fields Too Large when clients send
large cookies (common when mokey is served on a domain shared with
other applications) or when auth proxies add sizable headers.

Add a server.read_buffer_size config option wired to
fiber.Config.ReadBufferSize and raise the default to 16384.

Fixes #122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Request Header Fields Too Large

1 participant