Issues the requests and, on success, returns the Response
.
The write_progress
option field is a callback that will be called as the file body is uploaded. An optional state can be specified via the write_progress_state
the option field which is passed into the callback.
var res = try req.getResponse(.{
.write_progress = uploadProgress
});
fn uploadProgress(total: usize, written: usize, state: *anyopaque) void {
_ = state;
std.fmt.print("Written {d} of {d}", {written, total});
}
Or, with state:
var tracker = ProgressTracker{};
var res = try req.getResponse(.{
.write_progress = uploadProgress
.write_progress_state = &tracker,
});
fn uploadProgress(total: usize, written: usize, state: *anyopaque) void {
var tracker: *ProgressTracker = @alignCast(@ptrCast(state));
}