{"id":14990812,"url":"https://github.com/melonedo/zig-tls12","last_synced_at":"2025-04-12T03:24:24.889Z","repository":{"id":214491539,"uuid":"736654558","full_name":"melonedo/zig-tls12","owner":"melonedo","description":"HTTP client capable of TLS 1.2. ","archived":false,"fork":false,"pushed_at":"2024-05-21T15:26:01.000Z","size":297,"stargazers_count":27,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T23:01:37.854Z","etag":null,"topics":["tls","tls12","zig","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/melonedo.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-28T13:49:53.000Z","updated_at":"2025-03-15T17:53:47.000Z","dependencies_parsed_at":"2024-03-11T08:28:11.413Z","dependency_job_id":"5e56ec0a-107d-48a9-9c25-d9aead1f1a32","html_url":"https://github.com/melonedo/zig-tls12","commit_stats":{"total_commits":27,"total_committers":5,"mean_commits":5.4,"dds":0.2222222222222222,"last_synced_commit":"f2cbb846f8a98cb5e19c8476a8e6cf3b9bbcdb0c"},"previous_names":["melonedo/zig-tls12"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melonedo%2Fzig-tls12","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melonedo%2Fzig-tls12/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melonedo%2Fzig-tls12/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melonedo%2Fzig-tls12/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melonedo","download_url":"https://codeload.github.com/melonedo/zig-tls12/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248511043,"owners_count":21116339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["tls","tls12","zig","ziglang"],"created_at":"2024-09-24T14:20:53.827Z","updated_at":"2025-04-12T03:24:24.865Z","avatar_url":"https://github.com/melonedo.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zig-TLS12\n\nHTTP client capable of TLS 1.2.\n\nYou may use `HttpClient` in the same way you use `std.http.Client`.\nThe only difference of `HttpClient` from `std.http.Client` is that `std.crypto.tls.Client` which supports TLS 1.3 is replaced by a TLS 1.2 capable `TlsClient`.\n\n## Usage\n\nAdd to `build.zig.zon`:\n```zig\n.{\n    .dependencies = .{\n        // other dependencies...\n        .tls12 = .{\n            // Check releases for other versions\n            .url = \"https://github.com/melonedo/zig-tls12/archive/refs/heads/main.zip\",\n            // Let zon find out\n            .hash = \"12341234123412341234123412341234123412341234123412341234123412341234\",\n        },\n    },\n}\n```\n\nAdd to `build.zig`:\n```zig\n// const exe = b.addExecutable(...);\nconst tls12 = b.dependency(\"tls12\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"tls12\", tls12.module(\"zig-tls12\"));\n```\n\nIn zig program:\n```zig\n// Drop-in replacement of std.http.Client\nconst HttpClient = @import(\"tls12\");\n```\n\n## Example\n\nThis is tested againt zig version `0.12.0-dev.3674+a0de07760`. Zig's HTTP interface has changed so it DOES NOT WORK on 0.11 and below.\n\n```zig\nconst std = @import(\"std\");\n// With zon:    const HttpClient = @import(\"tls12\");\n// With stdlib: const HttpClient = std.http.Client;\nconst HttpClient = @import(\"HttpClient.zig\");\n\npub fn main() !void {\n    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);\n    defer arena.deinit();\n    const allocator = arena.allocator();\n\n    var client = HttpClient{ .allocator = allocator };\n    defer client.deinit();\n    try client.initDefaultProxies(allocator);\n\n    const url = \"https://httpbin.org\";\n\n    const uri = try std.Uri.parse(url);\n    var server_header_buffer: [1024 * 1024]u8 = undefined;\n    var req = try HttpClient.open(\u0026client, .GET, uri, .{\n        .server_header_buffer = \u0026server_header_buffer,\n        .redirect_behavior = @enumFromInt(10),\n    });\n    defer req.deinit();\n\n    try req.send();\n    try req.wait();\n    const body = try req.reader().readAllAlloc(allocator, 16 * 1024 * 1024);\n    defer allocator.free(body);\n\n    std.debug.print(\"{s}: {s}\\n\", .{ url, body });\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelonedo%2Fzig-tls12","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelonedo%2Fzig-tls12","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelonedo%2Fzig-tls12/lists"}