Skip to content

Commit

Permalink
Sync with f80376
Browse files Browse the repository at this point in the history
  • Loading branch information
melonedo committed Feb 27, 2024
1 parent 5ffca76 commit bf85ec5
Show file tree
Hide file tree
Showing 4 changed files with 637 additions and 587 deletions.
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The only difference of `HttpClient` from `std.http.Client` is that `std.crypto.t

## Example

This is tested againt zig version `0.12.0-dev.2341+92211135f`. Zig's HTTP interface has changed so it DOES NOT WORK on 0.11 and below.
This is tested againt zig version `0.12.0-dev.3049+f803761e1`(https://github.com/ziglang/zig/commit/f803761e13a65ccbc6a5508f2dc2d7723b010dab). Zig's HTTP interface has changed so it DOES NOT WORK on 0.11 and below.

```zig
const std = @import("std");
Expand All @@ -20,15 +20,16 @@ pub fn main() !void {
var client = HttpClient{ .allocator = allocator };
defer client.deinit();
try client.loadDefaultProxies();
try client.initDefaultProxies(allocator);
const url = "https://bing.com";
const uri = try std.Uri.parse(url);
var headers = std.http.Headers{ .allocator = allocator };
defer headers.deinit();
var req = try client.open(.GET, uri, headers, .{ .max_redirects = 10 });
var server_header_buffer: [1024 * 1024]u8 = undefined;
var req = try HttpClient.open(&client, .GET, uri, .{
.server_header_buffer = &server_header_buffer,
.redirect_behavior = @enumFromInt(10),
});
defer req.deinit();
try req.send(.{});
Expand Down
Loading

0 comments on commit bf85ec5

Please sign in to comment.