#[SOLVED] is there a way to put a `Request` body into a dynamic array
1 messages · Page 1 of 1 (latest)
is there a way to replace the buffer (just a pretty long []u8) with a dynamic array of some sort?
isn't there a req.readAllAlloc() method you can use?
if not, you might look though test/standalone/http.zig for examples
I think I figured something out, thanks!
gonna post a snippet here brb
fn fetchBody(
url: []const u8,
buf: *std.ArrayList(u8),
bufMaxSize: usize,
allocator: std.mem.Allocator,
) !void {
var headers = http.Headers{ .allocator = allocator };
defer headers.deinit();
var client = http.Client{ .allocator = allocator };
defer client.deinit();
const uri = try std.Uri.parse(url);
var req = try client.request(.GET, uri, headers, .{});
defer req.deinit();
try req.start();
try req.wait();
const reader = req.reader();
try reader.readAllArrayList(buf, bufMaxSize);
}```
something like this works fine