diff options
author | 2023-01-17 22:47:01 -0300 | |
---|---|---|
committer | 2023-01-17 17:47:01 -0800 | |
commit | c00fadab9e7f800fe519cc25731d5de029973012 (patch) | |
tree | e393f210818be6a96508582602d8b9aa0684211d /src/cli/upgrade_command.zig | |
parent | 9b260fb18b4b957674ad6cf284795c0ff2d8c7e7 (diff) | |
download | bun-c00fadab9e7f800fe519cc25731d5de029973012.tar.gz bun-c00fadab9e7f800fe519cc25731d5de029973012.tar.zst bun-c00fadab9e7f800fe519cc25731d5de029973012.zip |
feat(cli): Support `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` #1440 (#1814)
* WIP: http_proxy implemented, first steps for https_proxy #1440
* add HTTP_PROXY support to upgrade_command and WIP: tunneling
* WIP async handshake, stuck on WANT_READ, try to defer + check
* create and upgrade with proxy working, TLS and non-TLS to proxy TLS working
* bun install/upgrade/create working with http(s)_proxy #1440
* add NO_PROXY support #1440
* remove commented code and add TODO
* fix getHttpProxy no_proxy
* fix formatting
* refactor catch and getHttpProxy, fix empty strngs in env for proxy
* allow optimization for handleResponseBody
Diffstat (limited to 'src/cli/upgrade_command.zig')
-rw-r--r-- | src/cli/upgrade_command.zig | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index 80c7fe0cb..4880e8770 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -217,20 +217,13 @@ pub const UpgradeCommand = struct { } } + var http_proxy: ?URL = env_loader.getHttpProxy(api_url); + var metadata_body = try MutableString.init(allocator, 2048); // ensure very stable memory address var async_http: *HTTP.AsyncHTTP = allocator.create(HTTP.AsyncHTTP) catch unreachable; - async_http.* = HTTP.AsyncHTTP.initSync( - allocator, - .GET, - api_url, - header_entries, - headers_buf, - &metadata_body, - "", - 60 * std.time.ns_per_min, - ); + async_http.* = HTTP.AsyncHTTP.initSync(allocator, .GET, api_url, header_entries, headers_buf, &metadata_body, "", 60 * std.time.ns_per_min, http_proxy); if (!silent) async_http.client.progress_node = progress; const response = try async_http.sendSync(true); @@ -450,6 +443,9 @@ pub const UpgradeCommand = struct { }; } + var zip_url = URL.parse(version.zip_url); + var http_proxy: ?URL = env_loader.getHttpProxy(zip_url); + { var refresher = std.Progress{}; var progress = refresher.start("Downloading", version.size); @@ -458,16 +454,7 @@ pub const UpgradeCommand = struct { var zip_file_buffer = try ctx.allocator.create(MutableString); zip_file_buffer.* = try MutableString.init(ctx.allocator, @max(version.size, 1024)); - async_http.* = HTTP.AsyncHTTP.initSync( - ctx.allocator, - .GET, - URL.parse(version.zip_url), - .{}, - "", - zip_file_buffer, - "", - timeout, - ); + async_http.* = HTTP.AsyncHTTP.initSync(ctx.allocator, .GET, zip_url, .{}, "", zip_file_buffer, "", timeout, http_proxy); async_http.client.timeout = timeout; async_http.client.progress_node = progress; const response = try async_http.sendSync(true); |