aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-02-23 23:57:19 -0800
committerGravatar GitHub <noreply@github.com> 2023-02-23 23:57:19 -0800
commit3f04f8d0a653cf5decef2225c2044742b382718a (patch)
tree91eb6500834e3157ecb9ab208101aa368a1191c8 /src/http
parentb5bdde28ed34070cbb1d34d13f414f4c513ee40d (diff)
downloadbun-3f04f8d0a653cf5decef2225c2044742b382718a.tar.gz
bun-3f04f8d0a653cf5decef2225c2044742b382718a.tar.zst
bun-3f04f8d0a653cf5decef2225c2044742b382718a.zip
Upgrade Zig (#2151)
* fixup * Upgrade Zig * Remove bad assertion * strings * bump * mode -> optimize * optimize * Linux build * Update bindgen.zig
Diffstat (limited to '')
-rw-r--r--src/http.zig8
-rw-r--r--src/http/websocket.zig4
-rw-r--r--src/http/websocket_http_client.zig4
-rw-r--r--src/http_client_async.zig18
4 files changed, 17 insertions, 17 deletions
diff --git a/src/http.zig b/src/http.zig
index 8fcb078d1..5a2847357 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -478,7 +478,7 @@ pub const RequestContext = struct {
if (!this.bundler.options.routes.static_dir_enabled) return null;
const relative_path = this.url.path;
var extension = this.url.extname;
- var tmp_buildfile_buf = std.mem.span(&Bundler.tmp_buildfile_buf);
+ var tmp_buildfile_buf = Bundler.tmp_buildfile_buf[0..];
// On Windows, we don't keep the directory handle open forever because Windows doesn't like that.
const public_dir: std.fs.Dir = this.bundler.options.routes.static_dir_handle orelse std.fs.openDirAbsolute(this.bundler.options.routes.static_dir, .{}) catch |err| {
@@ -2387,7 +2387,7 @@ pub const RequestContext = struct {
if (send_sourcemap_info) {
// This will be cleared by the arena
- source_map_url = std.mem.span(chunky.rctx.getFullURLForSourceMap());
+ source_map_url = bun.asByteSlice(chunky.rctx.getFullURLForSourceMap());
chunky.rctx.appendHeader("SourceMap", source_map_url);
}
@@ -3362,7 +3362,7 @@ pub const Server = struct {
if (entries_option) |dir_ent| {
var last_file_hash: Watcher.HashType = std.math.maxInt(Watcher.HashType);
for (affected) |changed_name_ptr| {
- const changed_name: []const u8 = std.mem.span((changed_name_ptr orelse continue));
+ const changed_name: []u8 = (changed_name_ptr orelse continue)[0..];
if (changed_name.len == 0 or changed_name[0] == '~' or changed_name[0] == '.') continue;
const loader = (ctx.bundler.options.loaders.get(Fs.PathName.init(changed_name).ext) orelse .file);
@@ -3376,7 +3376,7 @@ pub const Server = struct {
file_ent.entry.need_stat = true;
path_string = file_ent.entry.abs_path;
file_hash = Watcher.getHash(path_string.slice());
- for (hashes) |hash, entry_id| {
+ for (hashes, 0..) |hash, entry_id| {
if (hash == file_hash) {
file_descriptors[entry_id] = 0;
break;
diff --git a/src/http/websocket.zig b/src/http/websocket.zig
index 5ab4fe690..8bc101abb 100644
--- a/src/http/websocket.zig
+++ b/src/http/websocket.zig
@@ -248,7 +248,7 @@ pub const Websocket = struct {
try stream.writeAll(mask);
// Encode
- for (dataframe.data) |c, i| {
+ for (dataframe.data, 0..) |c, i| {
try stream.writeByte(c ^ mask[i % 4]);
}
} else {
@@ -334,7 +334,7 @@ pub const Websocket = struct {
if (header.mask) {
const mask = buf[0..4];
// Decode data in place
- for (data) |_, i| {
+ for (data, 0..) |_, i| {
data[i] ^= mask[i % 4];
}
}
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig
index bc72f9e56..a4f9284d3 100644
--- a/src/http/websocket_http_client.zig
+++ b/src/http/websocket_http_client.zig
@@ -623,11 +623,11 @@ pub const Mask = struct {
}
if (comptime !skip_mask) {
- for (input) |c, i| {
+ for (input, 0..) |c, i| {
output[i] = c ^ mask[i % 4];
}
} else {
- for (input) |c, i| {
+ for (input, 0..) |c, i| {
output[i] = c;
}
}
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index 670bb2f7c..28a80700d 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -666,7 +666,7 @@ pub fn onOpen(
ssl.configureHTTPClient(hostname);
}
}
-
+
if (client.state.request_stage == .pending) {
client.onWritable(true, comptime is_ssl, socket);
}
@@ -920,7 +920,7 @@ pub const InternalState = struct {
body_out_str.list.expandToCapacity();
ZlibPool.decompress(buffer.list.items, body_out_str, default_allocator) catch |err| {
- Output.prettyErrorln("<r><red>Zlib error: {s}<r>", .{std.mem.span(@errorName(err))});
+ Output.prettyErrorln("<r><red>Zlib error: {s}<r>", .{bun.asByteSlice(@errorName(err))});
Output.flush();
return err;
};
@@ -939,7 +939,7 @@ pub const InternalState = struct {
else => {
if (!body_out_str.owns(buffer.list.items)) {
body_out_str.append(buffer.list.items) catch |err| {
- Output.prettyErrorln("<r><red>Failed to append to body buffer: {s}<r>", .{std.mem.span(@errorName(err))});
+ Output.prettyErrorln("<r><red>Failed to append to body buffer: {s}<r>", .{bun.asByteSlice(@errorName(err))});
Output.flush();
return err;
};
@@ -1053,12 +1053,12 @@ pub fn hashHeaderName(name: string) u64 {
var hasher = std.hash.Wyhash.init(0);
var remain: string = name;
var buf: [32]u8 = undefined;
- var buf_slice: []u8 = std.mem.span(&buf);
+ var buf_slice: []u8 = buf[0..32];
while (remain.len > 0) {
const end = @min(hasher.buf.len, remain.len);
- hasher.update(strings.copyLowercase(std.mem.span(remain[0..end]), buf_slice));
+ hasher.update(strings.copyLowercase(remain[0..end], buf_slice));
remain = remain[end..];
}
@@ -1386,7 +1386,7 @@ pub fn buildRequest(this: *HTTPClient, body_len: usize) picohttp.Request {
var override_user_agent = false;
- for (header_names) |head, i| {
+ for (header_names, 0..) |head, i| {
const name = this.headerStr(head);
// Hash it as lowercase
const hash = hashHeaderName(name);
@@ -1521,7 +1521,7 @@ pub fn start(this: *HTTPClient, body: []const u8, body_out_str: *MutableString)
fn start_(this: *HTTPClient, comptime is_ssl: bool) void {
// Aborted before connecting
- if (this.hasSignalAborted()){
+ if (this.hasSignalAborted()) {
this.fail(error.Aborted);
return;
}
@@ -1558,7 +1558,7 @@ fn printResponse(response: picohttp.Response) void {
}
pub fn onWritable(this: *HTTPClient, comptime is_first_call: bool, comptime is_ssl: bool, socket: NewHTTPContext(is_ssl).HTTPSocket) void {
- if (this.hasSignalAborted()) {
+ if (this.hasSignalAborted()) {
this.closeAndAbort(is_ssl, socket);
return;
}
@@ -2494,7 +2494,7 @@ pub fn handleResponseMetadata(
) !bool {
var location: string = "";
var pretend_304 = false;
- for (response.headers) |header, header_i| {
+ for (response.headers, 0..) |header, header_i| {
switch (hashHeaderName(header.name)) {
content_length_header_hash => {
const content_length = std.fmt.parseInt(@TypeOf(this.state.body_size), header.value, 10) catch 0;