We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6cced6b commit 2f0b85aCopy full SHA for 2f0b85a
src/examples/networking/http-post.zig
@@ -0,0 +1,27 @@
1
+const std = @import("std");
2
+
3
+const Client = std.http.Client;
4
5
+pub fn main() !void {
6
+ const allocator = std.heap.page_allocator;
7
8
+ var response: std.Io.Writer.Allocating = .init(allocator);
9
+ defer response.deinit();
10
11
+ var client: Client = .{
12
+ .allocator = allocator,
13
+ };
14
+ defer client.deinit();
15
16
+ _ = try client.fetch(.{
17
+ .method = .POST,
18
+ .location = .{
19
+ .url = "https://echo.free.beeceptor.com",
20
+ },
21
+ .payload = "Hello World",
22
+ .response_writer = &response.writer,
23
+ });
24
25
+ const response_data = try response.toOwnedSlice();
26
+ std.debug.print("{s}\n", .{response_data});
27
+}
0 commit comments