Zig
Zig
Clear All Multipart Parts
See more REST Examples
Demonstrates Rest.ClearAllParts, which removes all multipart subparts from the request under construction.
Background. Clearing the parts is useful when reusing the same Rest object to build a different multipart request.
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const rest = try chilkat.Rest.init();
defer rest.deinit();
const b_tls = true;
const b_auto_reconnect = true;
rest.connect("example.com", 443, b_tls, b_auto_reconnect) catch {
std.debug.print("{s}\n", .{try rest.getLastErrorText(alloc)});
return;
};
// Build a part.
rest.setPartSelector("1");
rest.setMultipartBodyString("value1") catch {
std.debug.print("{s}\n", .{try rest.getLastErrorText(alloc)});
return;
};
// Remove all multipart subparts from the request under construction, for example before reusing the
// same Rest object for a different multipart request.
rest.clearAllParts() catch {};
std.debug.print("All multipart parts cleared.\n", .{});
}