mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
more
This commit is contained in:
@@ -47,7 +47,7 @@ pub fn updateLifeCycle(this: *FetchTasklet) bun.JSTerminated!void {
|
||||
jsc.markBinding(@src());
|
||||
log("onProgressUpdate", .{});
|
||||
this.mutex.lock();
|
||||
this.has_schedule_callback.store(false, .monotonic);
|
||||
this.shared.has_schedule_callback.store(false, .monotonic);
|
||||
const is_done = !this.result.has_more;
|
||||
|
||||
const vm = this.javascript_vm;
|
||||
@@ -247,8 +247,8 @@ fn clearData(this: *FetchTasklet) void {
|
||||
this.request.metadata = null;
|
||||
}
|
||||
|
||||
this.shared.scheduled_response_buffer.deinit();
|
||||
this.response.deinit();
|
||||
this.response.scheduled_response_buffer.deinit();
|
||||
// this.response.deinit();
|
||||
if (this.response.native_response) |response| {
|
||||
this.response.native_response = null;
|
||||
|
||||
@@ -257,7 +257,7 @@ fn clearData(this: *FetchTasklet) void {
|
||||
|
||||
this.response.readable_stream_ref.deinit();
|
||||
|
||||
this.shared.scheduled_response_buffer.deinit();
|
||||
this.response.scheduled_response_buffer.deinit();
|
||||
if (this.request_body != .ReadableStream or this.is_waiting_request_stream_start) {
|
||||
this.request_body.detach();
|
||||
}
|
||||
@@ -455,7 +455,7 @@ export fn Bun__FetchResponse_finalize(this: *FetchTasklet) callconv(.c) void {
|
||||
// 3. We never started buffering, in which case we should ignore the body.
|
||||
//
|
||||
// Note: We cannot call .get() on the ReadableStreamRef. This is called inside a finalizer.
|
||||
if (body.* != .Locked or this.readable_stream_ref.held.has()) {
|
||||
if (body.* != .Locked or this.response.readable_stream_ref.held.has()) {
|
||||
// Scenario 1 or 3.
|
||||
return;
|
||||
}
|
||||
@@ -727,9 +727,9 @@ pub fn callback(task: *FetchTasklet, async_http: *bun.http.AsyncHTTP, result: bu
|
||||
if (task.ignore_data) {
|
||||
task.response_buffer.reset();
|
||||
|
||||
if (task.scheduled_response_buffer.list.capacity > 0) {
|
||||
task.scheduled_response_buffer.deinit();
|
||||
task.scheduled_response_buffer = .{
|
||||
if (task.response.scheduled_response_buffer.list.capacity > 0) {
|
||||
task.response.scheduled_response_buffer.deinit();
|
||||
task.response.scheduled_response_buffer = .{
|
||||
.allocator = bun.default_allocator,
|
||||
.list = .{
|
||||
.items = &.{},
|
||||
@@ -743,7 +743,7 @@ pub fn callback(task: *FetchTasklet, async_http: *bun.http.AsyncHTTP, result: bu
|
||||
}
|
||||
} else {
|
||||
if (success) {
|
||||
_ = bun.handleOom(task.scheduled_response_buffer.write(task.response_buffer.list.items));
|
||||
_ = bun.handleOom(task.response.scheduled_response_buffer.write(task.response_buffer.list.items));
|
||||
}
|
||||
// reset for reuse
|
||||
task.response_buffer.reset();
|
||||
|
||||
@@ -47,7 +47,7 @@ pub fn onReadableStreamAvailable(ctx: *anyopaque, globalThis: *jsc.JSGlobalObjec
|
||||
this.readable_stream_ref = jsc.WebCore.ReadableStream.Strong.init(readable, globalThis);
|
||||
}
|
||||
|
||||
pub fn checkServerIdentity(this: *FetchTasklet, certificate_info: http.CertificateInfo) bool {
|
||||
pub fn checkServerIdentity(this: *Response, certificate_info: http.CertificateInfo) bool {
|
||||
if (this.check_server_identity.get()) |check_server_identity| {
|
||||
check_server_identity.ensureStillAlive();
|
||||
if (certificate_info.cert.len > 0) {
|
||||
@@ -106,7 +106,7 @@ pub fn checkServerIdentity(this: *FetchTasklet, certificate_info: http.Certifica
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn onBodyReceived(this: *FetchTasklet) bun.JSTerminated!void {
|
||||
pub fn onBodyReceived(this: *Response) bun.JSTerminated!void {
|
||||
const success = this.result.isSuccess();
|
||||
const globalThis = this.global_this;
|
||||
// reset the buffer if we are streaming or if we are not waiting for bufferig anymore
|
||||
@@ -296,7 +296,7 @@ pub fn onStartStreamingHTTPResponseBodyCallback(ctx: *anyopaque) jsc.WebCore.Dra
|
||||
};
|
||||
}
|
||||
|
||||
fn getSizeHint(this: *FetchTasklet) Blob.SizeType {
|
||||
fn getSizeHint(this: *Response) Blob.SizeType {
|
||||
return switch (this.body_size) {
|
||||
.content_length => @truncate(this.body_size.content_length),
|
||||
.total_received => @truncate(this.body_size.total_received),
|
||||
@@ -304,7 +304,7 @@ fn getSizeHint(this: *FetchTasklet) Blob.SizeType {
|
||||
};
|
||||
}
|
||||
|
||||
fn toBodyValue(this: *FetchTasklet) Body.Value {
|
||||
fn toBodyValue(this: *Response) Body.Value {
|
||||
if (this.getAbortError()) |err| {
|
||||
return .{ .Error = err };
|
||||
}
|
||||
@@ -338,7 +338,7 @@ fn toBodyValue(this: *FetchTasklet) Body.Value {
|
||||
return response;
|
||||
}
|
||||
|
||||
fn ignoreRemainingResponseBody(this: *FetchTasklet) void {
|
||||
pub fn ignoreRemainingResponseBody(this: *Response) void {
|
||||
log("ignoreRemainingResponseBody", .{});
|
||||
// enabling streaming will make the http thread to drain into the main thread (aka stop buffering)
|
||||
// without a stream ref, response body or response instance alive it will just ignore the result
|
||||
@@ -360,7 +360,7 @@ fn ignoreRemainingResponseBody(this: *FetchTasklet) void {
|
||||
this.ignore_data = true;
|
||||
}
|
||||
|
||||
fn toResponse(this: *FetchTasklet) Response {
|
||||
fn toResponse(this: *Response) Response {
|
||||
log("toResponse", .{});
|
||||
bun.assert(this.metadata != null);
|
||||
// at this point we always should have metadata
|
||||
|
||||
Reference in New Issue
Block a user