mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
Make new HTTP client more stable
This commit is contained in:
@@ -1845,8 +1845,6 @@ pub const Example = struct {
|
||||
var mutable = try ctx.allocator.create(MutableString);
|
||||
mutable.* = try MutableString.init(ctx.allocator, 8096);
|
||||
|
||||
var request_body = try MutableString.init(ctx.allocator, 0);
|
||||
|
||||
// ensure very stable memory address
|
||||
var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
|
||||
async_http.* = HTTP.AsyncHTTP.initSync(
|
||||
@@ -1856,7 +1854,7 @@ pub const Example = struct {
|
||||
header_entries,
|
||||
headers_buf,
|
||||
mutable,
|
||||
&request_body,
|
||||
"",
|
||||
60 * std.time.ns_per_min,
|
||||
);
|
||||
async_http.client.progress_node = progress;
|
||||
@@ -1916,12 +1914,20 @@ pub const Example = struct {
|
||||
var mutable = try ctx.allocator.create(MutableString);
|
||||
mutable.* = try MutableString.init(ctx.allocator, 2048);
|
||||
|
||||
var request_body = try MutableString.init(ctx.allocator, 0);
|
||||
url = URL.parse(try std.fmt.bufPrint(&url_buf, "https://registry.npmjs.org/@bun-examples/{s}/latest", .{name}));
|
||||
|
||||
// ensure very stable memory address
|
||||
var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
|
||||
async_http.* = HTTP.AsyncHTTP.initSync(ctx.allocator, .GET, url, .{}, "", mutable, &request_body, 60 * std.time.ns_per_min);
|
||||
async_http.* = HTTP.AsyncHTTP.initSync(
|
||||
ctx.allocator,
|
||||
.GET,
|
||||
url,
|
||||
.{},
|
||||
"",
|
||||
mutable,
|
||||
"",
|
||||
60 * std.time.ns_per_min,
|
||||
);
|
||||
async_http.client.progress_node = progress;
|
||||
var response = try async_http.sendSync(true);
|
||||
|
||||
@@ -1993,7 +1999,16 @@ pub const Example = struct {
|
||||
mutable.reset();
|
||||
|
||||
// ensure very stable memory address
|
||||
async_http.* = HTTP.AsyncHTTP.initSync(ctx.allocator, .GET, URL.parse(tarball_url), .{}, "", mutable, &request_body, 60 * std.time.ns_per_min);
|
||||
async_http.* = HTTP.AsyncHTTP.initSync(
|
||||
ctx.allocator,
|
||||
.GET,
|
||||
URL.parse(tarball_url),
|
||||
.{},
|
||||
"",
|
||||
mutable,
|
||||
"",
|
||||
60 * std.time.ns_per_min,
|
||||
);
|
||||
async_http.client.progress_node = progress;
|
||||
|
||||
refresher.maybeRefresh();
|
||||
@@ -2018,7 +2033,6 @@ pub const Example = struct {
|
||||
url = URL.parse(examples_url);
|
||||
|
||||
var async_http: *HTTP.AsyncHTTP = ctx.allocator.create(HTTP.AsyncHTTP) catch unreachable;
|
||||
var request_body = try MutableString.init(ctx.allocator, 0);
|
||||
var mutable = try ctx.allocator.create(MutableString);
|
||||
mutable.* = try MutableString.init(ctx.allocator, 2048);
|
||||
|
||||
@@ -2029,7 +2043,7 @@ pub const Example = struct {
|
||||
.{},
|
||||
"",
|
||||
mutable,
|
||||
&request_body,
|
||||
"",
|
||||
60 * std.time.ns_per_min,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user