-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std.http: more proxy support, buffer writes, tls toggle #17407
Conversation
9a9fda6
to
6a430a4
Compare
hi @truemedian, thanks for working on http proxy, does this support socks5? I didn't see any socks5 protocol handling. related: #15048. |
No SOCKS support yet, just HTTP proxying (when you send a fully qualified uri to a proxy server and it makes a request for you) and HTTP tunneling (when you make a CONNECT request to a proxy to open a tunnel to the target). |
aef5515
to
b28f425
Compare
5f9d682
to
f0e981c
Compare
How's it going? You looking for a merge yet? |
I think so. I don't have anything else important to fix or add in this batch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I only have superficial changes requested, but one of them regards the public API, so I do think it should be changed before merging. After this however I think it is ready to land 👍
I forgot to mention, I think this PR solves #17422. |
This at least mostly solves #17422 for std.http.Client, but I don't want to close that yet because std.http.Server likely still suffers this problem. |
Looks ready to land to me, I think it only needs a zig fmt in order to pass the CI. |
adds connectTunnel to form a HTTP CONNECT tunnel to the desired host. Primarily implemented for proxies, but like connectUnix may be called by any user. adds loadDefaultProxies to load proxy information from common environment variables (http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY, all_proxy, ALL_PROXY). - no_proxy and NO_PROXY are currently unsupported. splits proxy into http_proxy and https_proxy, adds headers field for arbitrary headers to each proxy.
std_options.http_connection_pool_size removed in favor of ``` client.connection_pool.resize(client.allocator, size); ``` std_options.http_disable_tls will remove all https capability from std.http when true. Any https request will error with `error.TlsInitializationFailed`. Solves ziglang#17051.
Response.do was renamed to Response.start to mimic the naming scheme in http.Client
I am a newcomer to Zig and encountered a network link error when trying to compile zsl using Zig Under Chinese WIN10, loadDefaultProxies cannot use system settings correctly ZIG: 0.12.0-dev.1270+6c9d34bce The test code is as follows:
No proxy can be used to access http/https under cmd:
powershell Ability to use HTTP_ PROXY access to http, cannot use https_ Proxy access to https:
I hope to receive your help and support thanks. |
#17732 should fix both of these. |
zig project (ziglang/zig#17407) add client.loadDefaultProxies to loads proxy environment variables (http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY, all_proxy, ALL_PROXY).
std.http.Client Changes
Proxies are now separated, so HTTP and HTTPS requests can be diverted thru different proxies. Connection pool now accepts a
Allocator
instead of a*Client
for allocations. Now passes around a*Connection
instead of a*ConnectionPool.Node
.Writes are now buffered, and reads now use iovecs to reduce syscalls.
Adds
client.loadDefaultProxies
to loads proxy information from commonenvironment variables (http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY,
all_proxy, ALL_PROXY).
Other Associated Fixes
std.Uri
has expanded formatting capabilities so to enable more control over what appears in the output.std.crypto.tls.Client.readv
was evidently not tested, it was missing a parameter.std_options Changes
Removed
http_connection_pool_size
, Addedhttp_disable_tls
client.connection_pool.resize(client.allocator, size)
error.TlsInitializationFailed
, and std.http will make no references tostd.crypto.tls
(which may reduce the size of the overall binary, and potentially reduce compile times; unless referenced elsewhere).When compiling without TLS:
test/standalone/http.zig
compiles 10 seconds faster, and is half the size (aprox. -4MB in ReleaseSafe).Documentation
Adds documentation to public functions that was missing documentation. Adds information about when order-specific functions need to be called.
Revisited old documentation and pulled it in line with what each function is actually doing now.