Bug 1723518 [wpt PR 29866] - HTTP cache: Fix http-cache.js Header Fields Too Large...
commit6f585dac33489efd593cfbaf7927e9a752b9217d
authorBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Thu, 5 Aug 2021 21:11:08 +0000 (5 21:11 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Fri, 6 Aug 2021 09:42:48 +0000 (6 09:42 +0000)
tree93d8f461ef263e61cf9fe31767c423d6d80f2b03
parent92c801faa41389dcafd010478a75134e0c2932e4
Bug 1723518 [wpt PR 29866] - HTTP cache: Fix http-cache.js Header Fields Too Large., a=testonly

Automatic update from web-platform-tests
HTTP cache: Fix http-cache.js Header Fields Too Large. (#29866)

Due to a bug in http-cache.js, sending multiple requests can cause:
```
431 Request Header Fields Too Large
```

That's because the base64 encoded list of requests was added to ... the
list of requests ... iteratively. So the size of request was growing
quadratically relatively to the number of requests.

This has been fixed by copying the list of request instead of taking a
new reference.

Explanation: The code was executing iteratively:
- config = requests[idx];
- fetchInit(requests, config);
- init.headers = config['request_headers'];
- init.headers.push(['Test-Request', btoa(JSON.stringify(requests))]);

which equivalent to:

- requests[idx].requests_headers.push(
  ['Test-Request'], btoa(JSON.stringify(requests))]),

So we stringify "requests" and append the result into "requests"
iteratively => Boom.

Bug: 1221529
Change-Id: Ib9468d95daca2987dd7c391551387f3107dcb1bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3063967
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Maksim Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#908039}

Co-authored-by: Arthur Sonzogni <arthursonzogni@chromium.org>
--

wpt-commits: 34e20f134472dc923d02206fe13819681ca63155
wpt-pr: 29866
testing/web-platform/tests/fetch/http-cache/http-cache.js