mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
### Motivation: NIO's historic limit was that the maximum header block was limited to 80 kB which is a sensible limit and originates from Nginx's http_parser.c. The history of the changes: - commite67fc995: Introduces the 80 kB limit - commit69180342: Accidentally removes the limit entirely - commitb24872d3: Introduced the 2 MB / 256 headers limit I would argue that 2MB & 256 headers is a bad limit: - 2MB is way too big, that allows pretty powerful slowloris-style attacks forcing NIO to hold on to 2 MB per connection - 256 headers is too little for software that may be a proxy - in HTTP, the number of headers is _non-semantic_ - A: `a: 1\r\n a: 2\r\n a: 3\r\n a: 4\r\n a: 5\r\n a: 6\r\n[...]\r\na: 257\r\n` - B: `a: 1, 2, 3, 4, 5, ..., 257\r\n` - A & B are _equivalent_. Yet, A would be rejected and B accepted. That's not right. ### Modifications: Restore the old limits. ### Result: - More compatible (because we allow more than 256 headers) - More secure (because the default goes back to 80kB)