-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
- Run a local proxy server, say
mitmdump - Setup environment variables for http(s) proxy
export https_proxy=http://127.0.0.1:8080 - Make sure the proxy server is setup correctly. For example
curl https://httpbun.com/getshould work andmitmdumpshould show the request. - Then if you run this:
const std = @import("std"); pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); var client = std.http.Client{ .allocator = allocator }; defer client.deinit(); client.initDefaultProxies(allocator) catch |err| { std.debug.print("Unable to initialize default proxies: {}\n", .{err}); }; var response = std.ArrayList(u8).init(allocator); defer response.deinit(); // Can't use httpbin.org, see #14172. const result = try client.fetch(.{ .method = .GET, .location = .{ .url = "https://httpbun.com/get" }, .response_storage = .{ .dynamic = &response }, }); std.debug.print("Result: {}\n", .{result}); std.debug.print("Response: {s}\n", .{response.items}); }
- It's a bad request:
Result: http.Client.FetchResult{ .status = http.Status.bad_request } Response: Client sent an HTTP request to an HTTPS server.
Expected Behavior
The request is successful, through the proxy.
Result: http.Client.FetchResult{ .status = http.Status.ok }
Response: {
"method": "GET",
"args": {},
"headers": {
"Accept-Encoding": "gzip, deflate",
"Host": "httpbun.com",
"User-Agent": "zig/0.12.0 (std.http)"
},
"origin": "123.456.789.012",
"url": "http://httpbun.com/get",
"form": {},
"data": "",
"json": null,
"files": {}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.