Skip to content

Conversation

@tadejg
Copy link
Contributor

@tadejg tadejg commented Aug 31, 2025

The following example populates the Authorization header with user:user instead of user:password, due to a typo.

const std = @import("std");

pub fn main() !void {
    const allocator = std.heap.page_allocator;
    var client = std.http.Client{ .allocator = allocator };
    defer client.deinit();
    var response = std.io.Writer.Allocating.init(allocator);
    defer response.deinit();
    const stat = try client.fetch(.{
        .method = .POST,
        .location = .{
            .url = "http://user:password@127.0.0.1",
        },
        .headers = .{ .content_type = .{ .override = "application/json" } },
        .response_writer = &response.writer,
        .payload = "{}",
    });
    std.log.info("OK: status={s}, response={s}", .{ @tagName(stat.status), response.written() });
}

… instead of user:password when passed in URI
@andrewrk andrewrk merged commit 3aa31ff into ziglang:master Aug 31, 2025
12 of 14 checks passed
@andrewrk
Copy link
Member

Thanks!

@tadejg tadejg deleted the fix-regression-http-client-uri-basic-auth branch September 1, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants