diff options
author | 2022-11-19 22:34:57 -0800 | |
---|---|---|
committer | 2022-11-19 22:34:57 -0800 | |
commit | b230e7a73a78e67533cba0d852cefdbbd787eae9 (patch) | |
tree | c720a12d0bc6af9f8b3a6f053a8eefbb2ca50e76 /src/url.zig | |
parent | e024116b776efc19b92d4be613c1449213690ca1 (diff) | |
download | bun-b230e7a73a78e67533cba0d852cefdbbd787eae9.tar.gz bun-b230e7a73a78e67533cba0d852cefdbbd787eae9.tar.zst bun-b230e7a73a78e67533cba0d852cefdbbd787eae9.zip |
[fetch] Fix sporadic data corruption bug in HTTP client and add fast path
- This removes memory pooling from the HTTP client which sometimes caused invalid memory to be written to the response body.
- This adds a fast path for small HTTP/HTTPS responses that makes it a single memory allocation for the response body, instead of copying & allocating a temporary buffer
cc @Electroid
Diffstat (limited to 'src/url.zig')
-rw-r--r-- | src/url.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/url.zig b/src/url.zig index c212c3fe2..a4e0946fb 100644 --- a/src/url.zig +++ b/src/url.zig @@ -120,7 +120,11 @@ pub const URL = struct { } pub fn getPortAuto(this: *const URL) u16 { - return this.getPort() orelse (if (this.isHTTPS()) @as(u16, 443) else @as(u16, 80)); + return this.getPort() orelse this.getDefaultPort(); + } + + pub fn getDefaultPort(this: *const URL) u16 { + return if (this.isHTTPS()) @as(u16, 443) else @as(u16, 80); } pub fn hasValidPort(this: *const URL) bool { |