2022-01-12 17:18:16 +00:00
|
|
|
//! This module provides base data structures for aws http requests
|
|
|
|
const std = @import("std");
|
|
|
|
const log = std.log.scoped(.aws_base);
|
|
|
|
pub const Request = struct {
|
|
|
|
path: []const u8 = "/",
|
|
|
|
query: []const u8 = "",
|
|
|
|
body: []const u8 = "",
|
|
|
|
method: []const u8 = "POST",
|
|
|
|
content_type: []const u8 = "application/json", // Can we get away with this?
|
upgrade to nominated zig 2024.3.0-mach (0.12.0-dev.3180+83e578a18)
There were significant changes to the way HTTP operates since 0.11,
effecting client operations, but more substantially, the server
implementation, which effected the test harness.
std.http.Headers was removed, including the getFirstValue function, which
needed to be replicated. On the plus side, a std.http.Header struct was
added, identical to our own structure, so I have removed out own header
in favor of stdlib.
On the Http client side, I have switched to use the fetch API. Proxy
support is built in, but we are using (mostly) our own implementation
for now, with the remaining conversion left as a TODO item. Raw URIs are
now supported, so the workaround for issue 17015 has been removed. Large
payloads should also be fixed, but this has not been tested.
The standard library now adds the content-length header
(unconditionally), which is a decision of dubious nature. I have removed
the addition of content-length, which also means it is not present
during signing. This should be allowed.
Dependency loop on fieldTransformer was fixed. This should have been
a problem on zig 0.11, but was not. This effected the API for the json
parsing, but we were not using that. At the call site, these did not
need to be specified as references.
With the http server no longer doing all the allocations it once was,
the test harness now has a lot more allocations to perform. To alleviate
the bookeeping, this was moved to an Arena allocator. The client,
which is really what is under test, continues to use the allocator
passed.
2024-04-02 16:13:45 +00:00
|
|
|
headers: []const std.http.Header = &.{},
|
2022-01-12 17:18:16 +00:00
|
|
|
};
|
|
|
|
pub const Result = struct {
|
|
|
|
response_code: u16, // actually 3 digits can fit in u10
|
|
|
|
body: []const u8,
|
upgrade to nominated zig 2024.3.0-mach (0.12.0-dev.3180+83e578a18)
There were significant changes to the way HTTP operates since 0.11,
effecting client operations, but more substantially, the server
implementation, which effected the test harness.
std.http.Headers was removed, including the getFirstValue function, which
needed to be replicated. On the plus side, a std.http.Header struct was
added, identical to our own structure, so I have removed out own header
in favor of stdlib.
On the Http client side, I have switched to use the fetch API. Proxy
support is built in, but we are using (mostly) our own implementation
for now, with the remaining conversion left as a TODO item. Raw URIs are
now supported, so the workaround for issue 17015 has been removed. Large
payloads should also be fixed, but this has not been tested.
The standard library now adds the content-length header
(unconditionally), which is a decision of dubious nature. I have removed
the addition of content-length, which also means it is not present
during signing. This should be allowed.
Dependency loop on fieldTransformer was fixed. This should have been
a problem on zig 0.11, but was not. This effected the API for the json
parsing, but we were not using that. At the call site, these did not
need to be specified as references.
With the http server no longer doing all the allocations it once was,
the test harness now has a lot more allocations to perform. To alleviate
the bookeeping, this was moved to an Arena allocator. The client,
which is really what is under test, continues to use the allocator
passed.
2024-04-02 16:13:45 +00:00
|
|
|
headers: []const std.http.Header,
|
2022-01-12 17:18:16 +00:00
|
|
|
allocator: std.mem.Allocator,
|
|
|
|
|
|
|
|
pub fn deinit(self: Result) void {
|
|
|
|
self.allocator.free(self.body);
|
|
|
|
for (self.headers) |h| {
|
|
|
|
self.allocator.free(h.name);
|
|
|
|
self.allocator.free(h.value);
|
|
|
|
}
|
|
|
|
self.allocator.free(self.headers);
|
2024-08-27 18:30:23 +00:00
|
|
|
//log.debug("http result deinit complete", .{});
|
2022-01-12 17:18:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|