diff options
Diffstat (limited to 'src/http/websocket_http_client.zig')
-rw-r--r-- | src/http/websocket_http_client.zig | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index e1bd42984..e79c353e3 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -77,9 +77,9 @@ fn buildRequestBody( }; if (client_protocol.len > 0) - client_protocol_hash.* = std.hash.Wyhash.hash(0, static_headers[1].value); + client_protocol_hash.* = bun.hash(static_headers[1].value); - const headers_ = static_headers[0 .. 1 + @as(usize, @boolToInt(client_protocol.len > 0))]; + const headers_ = static_headers[0 .. 1 + @as(usize, @intFromBool(client_protocol.len > 0))]; const pathname_ = pathname.slice(); const host_ = host.slice(); @@ -289,7 +289,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.clearData(); if (!this.tcp.isEstablished()) { - _ = uws.us_socket_close_connecting(comptime @as(c_int, @boolToInt(ssl)), this.tcp.socket); + _ = uws.us_socket_close_connecting(comptime @as(c_int, @intFromBool(ssl)), this.tcp.socket); } else { this.tcp.close(0, null); } @@ -387,7 +387,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { const to_write = remain[0..@min(remain.len, data.len)]; if (data.len > 0 and to_write.len > 0) { - @memcpy(remain.ptr, data.ptr, to_write.len); + @memcpy(remain[0..to_write.len], data[0..to_write.len]); this.body_written += to_write.len; } @@ -465,7 +465,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { }, "Sec-WebSocket-Protocol".len => { if (strings.eqlCaseInsensitiveASCII(header.name, "Sec-WebSocket-Protocol", false)) { - if (this.websocket_protocol == 0 or std.hash.Wyhash.hash(0, header.value) != this.websocket_protocol) { + if (this.websocket_protocol == 0 or bun.hash(header.value) != this.websocket_protocol) { this.terminate(ErrorCode.mismatch_client_protocol); return; } @@ -524,7 +524,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { this.terminate(ErrorCode.invalid_response); return; }; - if (remain_buf.len > 0) @memcpy(overflow.ptr, remain_buf.ptr, remain_buf.len); + if (remain_buf.len > 0) @memcpy(overflow[0..remain_buf.len], remain_buf); } this.clearData(); @@ -775,7 +775,7 @@ const Copy = union(enum) { if (this == .raw) { std.debug.assert(buf.len >= this.raw.len); std.debug.assert(buf.ptr != this.raw.ptr); - @memcpy(buf.ptr, this.raw.ptr, this.raw.len); + @memcpy(buf[0..this.raw.len], this.raw); return; } @@ -914,7 +914,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { return; if (!this.tcp.isEstablished()) { - _ = uws.us_socket_close_connecting(comptime @as(c_int, @boolToInt(ssl)), this.tcp.socket); + _ = uws.us_socket_close_connecting(comptime @as(c_int, @intFromBool(ssl)), this.tcp.socket); } else { this.tcp.close(0, null); } @@ -1027,7 +1027,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { std.debug.assert(data_.len > 0); var writable = this.receive_buffer.writableWithSize(data_.len) catch unreachable; - @memcpy(writable.ptr, data_.ptr, data_.len); + @memcpy(writable[0..data_.len], data_); this.receive_buffer.update(data_.len); if (left_in_fragment >= data_.len and left_in_fragment - data_.len - this.receive_pending_chunk_len == 0) { @@ -1177,10 +1177,10 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { .ping => { const ping_len = @min(data.len, @min(receive_body_remain, 125)); - this.ping_len = @truncate(u8, ping_len); + this.ping_len = ping_len; if (ping_len > 0) { - @memcpy(this.ping_frame_bytes[6..], data.ptr, ping_len); + @memcpy(this.ping_frame_bytes[6..][0..ping_len], data[0..ping_len]); data = data[ping_len..]; } @@ -1379,7 +1379,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { std.mem.writeIntSliceBig(u16, final_body_bytes[6..8], code); if (body) |data| { - if (body_len > 0) @memcpy(final_body_bytes[8..], data, body_len); + if (body_len > 0) @memcpy(final_body_bytes[8..][0..body_len], data[0..body_len]); } // we must mask the code @@ -1565,7 +1565,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { this.adopted.receive_buffer.ensureUnusedCapacity(this.slice.len) catch return; var writable = this.adopted.receive_buffer.writableSlice(0); - @memcpy(writable.ptr, this.slice.ptr, this.slice.len); + @memcpy(writable[0..this.slice.len], this.slice); this.adopted.handleData(this.adopted.tcp, writable); } |