diff --git a/src/aws_http.zig b/src/aws_http.zig index 7d4f674..bd3fa39 100644 --- a/src/aws_http.zig +++ b/src/aws_http.zig @@ -129,14 +129,15 @@ pub const AwsHttp = struct { defer if (len) |l| self.allocator.free(l); request_cp.headers = request_headers.items; - log.debug("All Request Headers (before signing. Count: {d}):", .{request_cp.headers.len}); - for (request_cp.headers) |h| - log.debug("\t{s}: {s}", .{ h.name, h.value }); - // Signing will alter request headers + // log.debug("All Request Headers (before signing. Count: {d}):", .{request_cp.headers.len}); + // for (request_cp.headers) |h| { + // log.debug("\t{s}: {s}", .{ h.name, h.value }); + // } if (signing_config) |opts| request_cp = try signing.signRequest(self.allocator, request_cp, opts); - log.debug("All Request Headers (after signing):", .{}); - for (request_cp.headers) |h| - log.debug("\t{s}: {s}", .{ h.name, h.value }); + // log.debug("All Request Headers (after signing):", .{}); + // for (request_cp.headers) |h| { + // log.debug("\t{s}: {s}", .{ h.name, h.value }); + // } defer { if (signing_config) |opts| { signing.freeSignedRequest(self.allocator, &request_cp, opts); @@ -150,12 +151,16 @@ pub const AwsHttp = struct { for (request_cp.headers) |header| try headers.appendValue(header.name, header.value); log.debug("All Request Headers (zfetch):", .{}); - for (headers.list.items) |h| + for (headers.list.items) |h| { log.debug("\t{s}: {s}", .{ h.name, h.value }); + } // TODO: Construct URL with endpoint and request info // TODO: We need the certificate trust chain - var req = try zfetch.Request.init(self.allocator, "https://sts.us-west-2.amazonaws.com/", null); + const url = try std.fmt.allocPrint(self.allocator, "{s}{s}", .{ endpoint.uri, request.path }); + defer self.allocator.free(url); + log.debug("Request url: {s}", .{url}); + var req = try zfetch.Request.init(self.allocator, url, null); defer req.deinit(); const method = std.meta.stringToEnum(zfetch.Method, request_cp.method).?; diff --git a/src/aws_signing.zig b/src/aws_signing.zig index 5958142..f597dc8 100644 --- a/src/aws_signing.zig +++ b/src/aws_signing.zig @@ -165,8 +165,6 @@ pub fn signRequest(allocator: std.mem.Allocator, request: base.Request, config: .value = signing_iso8601, }; rc.headers = newheaders[0 .. newheaders.len - 1]; - for (rc.headers) |h| - std.log.debug("{d}/{d}", .{ h.name.len, h.value.len }); log.debug("Signing with access key: {s}", .{config.credentials.access_key}); const canonical_request = try createCanonicalRequest(allocator, rc, config); defer { diff --git a/src/main.zig b/src/main.zig index ba55c0e..8de5e0f 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,7 +3,7 @@ const aws = @import("aws.zig"); const json = @import("json.zig"); const version = @import("git_version.zig"); -var verbose = true; +var verbose: u8 = 0; pub fn log( comptime level: std.log.Level, @@ -11,8 +11,11 @@ pub fn log( comptime format: []const u8, args: anytype, ) void { + // Ignore aws_signing messages + if (verbose < 2 and scope == .aws_signing and @enumToInt(level) >= @enumToInt(std.log.Level.debug)) + return; // Ignore awshttp messages - if (!verbose and scope == .awshttp and @enumToInt(level) >= @enumToInt(std.log.Level.debug)) + if (verbose < 1 and scope == .awshttp and @enumToInt(level) >= @enumToInt(std.log.Level.debug)) return; const scope_prefix = "(" ++ @tagName(scope) ++ "): "; const prefix = "[" ++ @tagName(level) ++ "] " ++ scope_prefix; @@ -52,7 +55,7 @@ pub fn main() anyerror!void { std.log.info("{s} {s}", .{ arg, version.pretty_version }); first = false; if (std.mem.eql(u8, "-v", arg)) { - verbose = true; + verbose += 1; continue; } inline for (@typeInfo(Tests).Enum.fields) |f| {