HTTP header parsing fails for header lines > 4096 bytes (fixed buffer limitation)
When using the POCO C++ HTTP server, header parsing fails if a single HTTP header line exceeds the internal buffer size (HTTPBufferAllocator::BUFFER_SIZE, default 4096 bytes).
Problem Details
The HTTP parser reads headers line-by-line using a fixed-size buffer.
If a single header line (header name + value) exceeds this size:
- The line may be truncated or rejected
- Parsing can stop prematurely
- Subsequent headers may not be parsed
- No clear or explicit error is consistently reported
This is especially problematic for modern authentication scenarios, such as large JWT bearer tokens in the Authorization header.
Reproduction Scenario
- Send an HTTP request containing a very large header value, for example:
Authorization: Bearer <~4000+ character JWT> X-Test: value
- Observe the behavior in the POCO HTTP server:
- Authorization may fail or the header may be only partially read
X-Testand subsequent headers may be missing from the parsed request
Expected Behavior
The HTTP parser should do one of the following:
- Handle header lines larger than 4096 bytes, within a reasonable configurable limit
- Provide a configurable buffer size for header parsing
- Cleanly reject oversized headers with an explicit and documented error
Actual Behavior
- Parsing stops silently or only partially completes
- Following headers are ignored
- There is no obvious supported configuration to increase the limit without modifying POCO source code
Environment
- OS: Linux
- POCO Version: 1.12.1
Suggested Improvements
Option 1 (recommended) Make the buffer size configurable, for example via an API such as:
HTTPBufferAllocator::setBufferSize(size_t size);
Option 2 Increase the default buffer size.
Option 3
Replace the fixed-size buffer with a dynamically growing buffer (for example using std::string or equivalent).
Source: pocoproject/poco