Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.0.0+

Example: Http.HttpBd method

Shows how to use the HttpBd method to send an HTTP POST request with the contents of a BinData as the request body. The example sends the following request:
POST /api/v1/sites/123/deploys HTTP/1.1
Host: example.com
Accept: */*
Accept-Encoding: gzip
Content-Type: application/zip
Content-Length: 123456

[binary data bytes of the BinData]

Also see: Chilkat Http Default and Auto-Filled Headers

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    const local_file_path = "C:/example/zips/data.zip";
    const bd = try chilkat.BinData.init();
    defer bd.deinit();
    bd.loadFile(local_file_path) catch {
        std.debug.print("{s}\n", .{try bd.getLastErrorText(alloc)});
        return;
    };

    const url = "https://example.com/api/v1/sites/123/deploys";

    // Send a POST with the contents of the BinData in the binary HTTP request body.
    const resp = try chilkat.HttpResponse.init();
    defer resp.deinit();
    const http = try chilkat.Http.init();
    defer http.deinit();
    http.httpBd("POST", url, bd, "application/zip", resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("Response Status Code: {d}\n", .{resp.getStatusCode()});
    std.debug.print("Response body:\n", .{});
    std.debug.print("{s}\n", .{try resp.getBodyStr(alloc)});
}