diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-04-13 02:46:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 02:46:33 +0200 |
commit | dabce813e064b7b3a2197cb327bde00e7b403688 (patch) | |
tree | af12a13b6fd770de42573bffa4b8261bee246529 /runtime/js/40_http.js | |
parent | 9f26e639dd6ddc9416bfd4d12b87efdac2699b1d (diff) |
perf: lazy header instantiation for HTTP requests (#10150)
This commit introduces a performance optimization for the native HTTP
server. From my testing it is about 2-6% faster than `main`. Request
headers in the HTTP servers are now lazilly instatated when they are
accessed, rather than being preemptively wrapped in the `Headers` class.
Diffstat (limited to 'runtime/js/40_http.js')
-rw-r--r-- | runtime/js/40_http.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/runtime/js/40_http.js b/runtime/js/40_http.js index 4a2dcdf4a..18ead84c3 100644 --- a/runtime/js/40_http.js +++ b/runtime/js/40_http.js @@ -2,7 +2,7 @@ "use strict"; ((window) => { - const { Request, dontValidateUrl, fastBody, Response } = + const { Request, dontValidateUrl, lazyHeaders, fastBody, Response } = window.__bootstrap.fetch; const { Headers } = window.__bootstrap.headers; const errors = window.__bootstrap.errors.errors; @@ -61,8 +61,9 @@ const request = new Request(url, { body, method, - headers: new Headers(headersList), + headers: headersList, [dontValidateUrl]: true, + [lazyHeaders]: true, }); const respondWith = createRespondWith(responseSenderRid, this.#rid); |