Skip to content

Commit abce536

Browse files
committed
chore: ensure compilation across examples
1 parent 10952bf commit abce536

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

examples/multithread/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn hi_handler(ctx: *Context) !void {
4444
}
4545

4646
fn redir_handler(ctx: *Context) !void {
47-
ctx.response.headers.putAssumeCapacity("Location", "/hi/redirect");
47+
ctx.response.headers.put_assume_capacity("Location", "/hi/redirect");
4848

4949
try ctx.respond(.{
5050
.status = .@"Permanent Redirect",

src/core/case_string_map.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn CaseStringMap(comptime T: type) type {
3939
entry.item.* = .{ .key = name, .hash = name_hash, .data = data };
4040
}
4141

42-
pub fn get(self: *Self, name: []const u8) ?T {
42+
pub fn get(self: *const Self, name: []const u8) ?T {
4343
const name_hash = hash(name);
4444

4545
var iter = self.pool.iterator();

src/http/router/fs_dir.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn FsDir(Server: type, AppState: type) type {
8989
.{etag_hash},
9090
);
9191

92-
provision.response.headers.putAssumeCapacity("ETag", calc_etag);
92+
provision.response.headers.put_assume_capacity("ETag", calc_etag);
9393

9494
// If we have an ETag on the request...
9595
if (provision.request.headers.get("If-None-Match")) |etag| {

src/http/router/route.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn Route(comptime Server: type, comptime AppState: type) type {
167167
.{std.time.s_per_day * 30},
168168
);
169169

170-
ctx.response.headers.putAssumeCapacity("Cache-Control", cache_control);
170+
ctx.response.headers.put_assume_capacity("Cache-Control", cache_control);
171171

172172
// If our static item is greater than 1KB,
173173
// it might be more beneficial to using caching.
@@ -177,7 +177,7 @@ pub fn Route(comptime Server: type, comptime AppState: type) type {
177177
"\"{d}\"",
178178
.{std.hash.Wyhash.hash(0, bytes)},
179179
);
180-
ctx.response.headers.putAssumeCapacity("ETag", etag[0..]);
180+
ctx.response.headers.put_assume_capacity("ETag", etag[0..]);
181181

182182
if (ctx.request.headers.get("If-None-Match")) |match| {
183183
if (std.mem.eql(u8, etag, match)) {

src/http/server.zig

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
355355
fn recv_task(rt: *Runtime, result: RecvResult, provision: *Provision) !void {
356356
assert(provision.job == .recv);
357357

358-
const length = result.unwrap() catch |e| {
358+
// recv_count is how many bytes we have read off the socket
359+
const recv_count = result.unwrap() catch |e| {
359360
if (e != error.Closed) {
360361
log.warn("socket recv failed | {}", .{e});
361362
}
@@ -369,18 +370,8 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
369370

370371
const recv_job = &provision.job.recv;
371372

372-
// If the socket is closed.
373-
if (length <= 0) {
374-
provision.job = .close;
375-
try rt.net.close(provision, close_task, provision.socket);
376-
return;
377-
}
378-
379373
log.debug("{d} - recv triggered", .{provision.index});
380374

381-
// recv_count is how many bytes we have read off the socket
382-
const recv_count: usize = @intCast(length);
383-
384375
// this is how many http bytes we have received
385376
const http_bytes_count: usize = blk: {
386377
if (comptime security == .tls) {
@@ -468,7 +459,7 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
468459
try handshake_inner_task(rt, length, provision);
469460
}
470461

471-
fn handshake_inner_task(rt: *Runtime, length: i32, provision: *Provision) !void {
462+
fn handshake_inner_task(rt: *Runtime, length: usize, provision: *Provision) !void {
472463
assert(security == .tls);
473464
if (comptime security == .tls) {
474465
const tls_slice = rt.storage.get("__zzz_tls_slice", []TLSType);
@@ -488,11 +479,9 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
488479
return error.TLSHandshakeTooManyCycles;
489480
}
490481

491-
const hs_length: usize = @intCast(length);
492-
493482
const hstate = switch (handshake_job.state) {
494-
.recv => tls_ptr.*.?.continue_handshake(.{ .recv = @intCast(hs_length) }),
495-
.send => tls_ptr.*.?.continue_handshake(.{ .send = @intCast(hs_length) }),
483+
.recv => tls_ptr.*.?.continue_handshake(.{ .recv = length }),
484+
.send => tls_ptr.*.?.continue_handshake(.{ .send = length }),
496485
} catch |e| {
497486
log.err("{d} - tls handshake failed={any}", .{ provision.index, e });
498487
provision.job = .close;
@@ -618,7 +607,7 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
618607
assert(provision.job == .send);
619608
const config = rt.storage.get_const_ptr("__zzz_config", ServerConfig);
620609

621-
const length = result.unwrap() catch |e| {
610+
const send_count = result.unwrap() catch |e| {
622611
// If the socket is closed.
623612
if (e != error.ConnectionReset) {
624613
log.warn("socket send failed: {}", .{e});
@@ -631,7 +620,6 @@ pub fn Server(comptime security: Security, comptime AppState: type) type {
631620
const send_job = &provision.job.send;
632621

633622
log.debug("{d} - send triggered", .{provision.index});
634-
const send_count: usize = @intCast(length);
635623
log.debug("{d} - sent length: {d}", .{ provision.index, send_count });
636624

637625
switch (comptime security) {

src/tls/bear.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,9 @@ pub const TLS = struct {
563563

564564
pub const HandshakeInput = union(enum) {
565565
// this is the length of the recv to ack.
566-
recv: u32,
566+
recv: usize,
567567
// this is the length of the send to ack.
568-
send: u32,
568+
send: usize,
569569
};
570570

571571
const HandshakeState = union(enum) {

0 commit comments

Comments
 (0)