Skip to content

Commit 7ea3fca

Browse files
committed
Migrate router.max_header_bytes to router.max_header_kb
1 parent 53f6f68 commit 7ea3fca

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

jobs/gorouter/spec

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,13 @@ properties:
207207
router.route_services_timeout:
208208
description: "Expiry time of a route service signature in seconds"
209209
default: 60
210-
router.max_header_bytes:
210+
router.max_header_kb:
211211
description: |
212-
This value controls the maximum number of bytes the gorouter will read
212+
This value controls the maximum number of bytes (in KB) the gorouter will read
213213
parsing the request header's keys and values, including the request
214-
line. It does not limit the size of the request body. An additional
215-
padding of 4096 bytes is added to this value by go. Requests with
216-
larger headers will result in a 431 status code.
217-
default: 1048576 # 1Mb
214+
line. It does not limit the size of the request body. Requests with
215+
larger headers will result in a 431 status code. Must be between 1 and 1024kb.
216+
default: 1024 # 1Mb
218217
router.extra_headers_to_log:
219218
description: "An array of headers that access log events will be annotated with. This only applies to headers on requests."
220219
default: []

jobs/gorouter/templates/gorouter.yml.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def parse_ip (ip, var_name)
2828
end
2929
end
3030

31-
def validate_max_header_bytes (bytes)
32-
if bytes < 1 or bytes > 1024 * 1024
33-
raise "Invalid router.max_header_bytes value. Must be between 1 and 1,048,576 bytes"
31+
def validate_max_header_kb (kb)
32+
if kb < 1 or kb > 1024
33+
raise "Invalid router.max_header_kb value. Must be between 1 and 1,024 kb"
3434
end
35-
bytes
35+
kb * 1024
3636
end
3737

3838
parse_ip(p('router.debug_address'), 'router.debug_address')
@@ -89,7 +89,7 @@ params = {
8989
'route_services_hairpinning' => p('router.route_services_internal_lookup'),
9090
'route_services_hairpinning_allowlist' => p('router.route_services_internal_lookup_allowlist'),
9191
'extra_headers_to_log' => p('router.extra_headers_to_log'),
92-
'max_header_bytes' => validate_max_header_bytes(p('router.max_header_bytes')),
92+
'max_header_bytes' => validate_max_header_kb(p('router.max_header_kb')),
9393
'token_fetcher_max_retries' => 3,
9494
'token_fetcher_retry_interval' => '5s',
9595
'token_fetcher_expiration_buffer_time' => 30,

spec/gorouter_templates_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
'route_services_secret_decrypt_only' => 'secret',
170170
'route_services_recommend_https' => false,
171171
'extra_headers_to_log' => 'test-header',
172-
'max_header_bytes' => 1_048_576,
172+
'max_header_kb' => 1_024,
173173
'enable_proxy' => false,
174174
'force_forwarded_proto_https' => false,
175175
'sanitize_forwarded_proto' => false,
@@ -250,8 +250,8 @@
250250
end
251251
end
252252

253-
describe 'max_header_bytes' do
254-
it 'should set max_header_bytes' do
253+
describe 'max_header_kb' do
254+
it 'should set max_header_kb' do
255255
expect(parsed_yaml['max_header_bytes']).to eq(1_048_576)
256256
end
257257
end
@@ -1071,22 +1071,22 @@
10711071
end
10721072
end
10731073

1074-
context 'max_header_bytes' do
1074+
context 'max_header_kb' do
10751075
context 'less than 1' do
10761076
before do
1077-
deployment_manifest_fragment['router']['max_header_bytes'] = 0
1077+
deployment_manifest_fragment['router']['max_header_kb'] = 0
10781078
end
10791079
it 'throws an error' do
1080-
expect { parsed_yaml }.to raise_error(/Invalid router.max_header_bytes/)
1080+
expect { parsed_yaml }.to raise_error(/Invalid router.max_header_kb/)
10811081
end
10821082
end
10831083

10841084
context 'greater than 1mb' do
10851085
before do
1086-
deployment_manifest_fragment['router']['max_header_bytes'] = 1024 * 1024 + 1
1086+
deployment_manifest_fragment['router']['max_header_kb'] = 1024 + 1
10871087
end
10881088
it 'throws an error' do
1089-
expect { parsed_yaml }.to raise_error(/Invalid router.max_header_bytes/)
1089+
expect { parsed_yaml }.to raise_error(/Invalid router.max_header_kb/)
10901090
end
10911091
end
10921092
end

0 commit comments

Comments
 (0)