mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Implement Network.getResponseBody
Add response_data event, CDP now captures the full body so that it can respond to the Network.getResponseBody. This isn't memory efficient, but I don't see another way to do it. At least this way, it's only capturing/storing every response body when (a) CDP is used and (b) Network.enabled is called. That is, as opposed to baking this into Http/Client.zig, which would force the memory consumption for all use-cases. There's arguably some optimizations we could make for XHR requests, which also dupe/own the response. As of now, the response is dupe'd separately for CDP and XHR.
This commit is contained in:
@@ -757,7 +757,7 @@ pub const Transfer = struct {
|
||||
};
|
||||
|
||||
if (transfer.client.notification) |notification| {
|
||||
notification.dispatch(.http_headers_done, &.{
|
||||
notification.dispatch(.http_response_header_done, &.{
|
||||
.transfer = transfer,
|
||||
});
|
||||
}
|
||||
@@ -780,10 +780,19 @@ pub const Transfer = struct {
|
||||
}
|
||||
|
||||
transfer.bytes_received += chunk_len;
|
||||
transfer.req.data_callback(transfer, buffer[0..chunk_len]) catch |err| {
|
||||
const chunk = buffer[0..chunk_len];
|
||||
transfer.req.data_callback(transfer, chunk) catch |err| {
|
||||
log.err(.http, "data_callback", .{ .err = err, .req = transfer });
|
||||
return c.CURL_WRITEFUNC_ERROR;
|
||||
};
|
||||
|
||||
if (transfer.client.notification) |notification| {
|
||||
notification.dispatch(.http_response_data, &.{
|
||||
.data = chunk,
|
||||
.transfer = transfer,
|
||||
});
|
||||
}
|
||||
|
||||
return chunk_len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user