mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-03 22:13:46 +00:00
Fix [I hope] blocking auth interception
On a blocking request that requires authentication, we now handle the two cases
correctly:
1 - if the request is aborted, we don't continue processing (if we did, that
would result in (a) transfer.deinit being called twice and (b) the callbacks
being called twice
2 - if the request is "continue", we queue the transfer to be re-issued, as
opposed to just processing it as-is. We have to queue it because we're
currently inside a process loop and it [probaby] isn't safe to re-enter it.
By using the queue, we wait until the next call to `tick` to re-issue the
request.
This commit is contained in:
@@ -681,10 +681,6 @@ pub const Script = struct {
|
||||
});
|
||||
}
|
||||
|
||||
// If this isn't true, then we'll likely leak memory. If you don't
|
||||
// set `CURLOPT_SUPPRESS_CONNECT_HEADERS` and CONNECT to a proxy, this
|
||||
// will fail. This assertion exists to catch incorrect assumptions about
|
||||
// how libcurl works, or about how we've configured it.
|
||||
lp.assert(self.source.remote.capacity == 0, "ScriptManager.HeaderCallback", .{ .capacity = self.source.remote.capacity });
|
||||
var buffer = self.manager.buffer_pool.get();
|
||||
if (transfer.getContentLength()) |cl| {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
const std = @import("std");
|
||||
const lp = @import("lightpanda");
|
||||
|
||||
const log = @import("../log.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
@@ -238,7 +240,7 @@ pub fn request(self: *Client, req: Request) !void {
|
||||
if (req.blocking == false) {
|
||||
// The request was interecepted, but it isn't a blocking request, so we
|
||||
// dont' need to block this call. The request will be unblocked
|
||||
// asynchronously via eitehr continueTransfer or abortTransfer
|
||||
// asynchronously via either continueTransfer or abortTransfer
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -463,7 +465,7 @@ pub fn disableTlsVerify(self: *const Client) !void {
|
||||
}
|
||||
}
|
||||
|
||||
fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) !void {
|
||||
fn makeRequest(self: *Client, handle: *Handle, transfer: *Transfer) anyerror!void {
|
||||
const conn = handle.conn;
|
||||
const easy = conn.easy;
|
||||
const req = &transfer.req;
|
||||
@@ -587,7 +589,18 @@ fn processMessages(self: *Client) !bool {
|
||||
continue;
|
||||
}
|
||||
|
||||
_ = try self.waitForInterceptedResponse(transfer);
|
||||
self.endTransfer(transfer);
|
||||
if (try self.waitForInterceptedResponse(transfer)) {
|
||||
// we've been asked to continue with the request
|
||||
// we can't process it here, since we're already inside
|
||||
// a process, so we need to queue it and wait for the
|
||||
// next tick.
|
||||
self.queue.append(&transfer._node);
|
||||
} else {
|
||||
// aborted, already cleaned up
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -887,10 +900,19 @@ pub const Transfer = struct {
|
||||
};
|
||||
|
||||
pub fn reset(self: *Transfer) void {
|
||||
// There's an assertion in ScriptManager that's failing. Seemingly because
|
||||
// the headerCallback is being called multiple times. This shouldn't be
|
||||
// possible (hence the assertion). Previously, this `reset` would set
|
||||
// _header_done_called = false. That could have been how headerCallback
|
||||
// was called multuple times (because _header_done_called is the guard
|
||||
// against that, so resetting it would allow a 2nd call to headerCallback).
|
||||
// But it should also be impossible for this to be true. So, I've added
|
||||
// this assertion to try to narrow down what's going on.
|
||||
lp.assert(self._header_done_called == false, "Transert.reset header_done_called", .{});
|
||||
|
||||
self._redirecting = false;
|
||||
self._auth_challenge = null;
|
||||
self._notified_fail = false;
|
||||
self._header_done_called = false;
|
||||
self.response_header = null;
|
||||
self.bytes_received = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user