mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-30 17:18:57 +00:00
Compare commits
4 Commits
semantic-t
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47afdc003a | ||
|
|
7606528b37 | ||
|
|
9ca6bf42ae | ||
|
|
a272a2c314 |
14
.github/workflows/e2e-test.yml
vendored
14
.github/workflows/e2e-test.yml
vendored
@@ -100,14 +100,14 @@ jobs:
|
||||
./proxy/proxy & echo $! > PROXY.id
|
||||
./lightpanda serve --http-proxy 'http://127.0.0.1:3000' & echo $! > LPD.pid
|
||||
go run runner/main.go
|
||||
URL=https://demo-browser.lightpanda.io/campfire-commerce/ node puppeteer/proxy_auth.js
|
||||
kill `cat LPD.pid` `cat PROXY.id`
|
||||
|
||||
- name: run request interception through proxy
|
||||
- name: run request interception through proxy and playwright
|
||||
run: |
|
||||
export PROXY_USERNAME=username PROXY_PASSWORD=password
|
||||
./proxy/proxy & echo $! > PROXY.id
|
||||
./lightpanda serve & echo $! > LPD.pid
|
||||
URL=https://demo-browser.lightpanda.io/campfire-commerce/ node puppeteer/proxy_auth.js
|
||||
BASE_URL=https://demo-browser.lightpanda.io/ node playwright/proxy_auth.js
|
||||
kill `cat LPD.pid` `cat PROXY.id`
|
||||
|
||||
@@ -161,14 +161,18 @@ jobs:
|
||||
--http-proxy 'http://127.0.0.1:3000' \
|
||||
& echo $! > LPD.pid
|
||||
go run runner/main.go
|
||||
URL=https://demo-browser.lightpanda.io/campfire-commerce/ node puppeteer/proxy_auth.js
|
||||
kill `cat LPD.pid` `cat PROXY.id`
|
||||
|
||||
- name: run request interception through proxy
|
||||
- name: run request interception through proxy and playwright
|
||||
run: |
|
||||
export PROXY_USERNAME=username PROXY_PASSWORD=password
|
||||
./proxy/proxy & echo $! > PROXY.id
|
||||
./lightpanda serve & echo $! > LPD.pid
|
||||
URL=https://demo-browser.lightpanda.io/campfire-commerce/ node puppeteer/proxy_auth.js
|
||||
./lightpanda serve \
|
||||
--web-bot-auth-key-file private_key.pem \
|
||||
--web-bot-auth-keyid ${{ vars.WBA_KEY_ID }} \
|
||||
--web-bot-auth-domain ${{ vars.WBA_DOMAIN }} \
|
||||
& echo $! > LPD.pid
|
||||
BASE_URL=https://demo-browser.lightpanda.io/ node playwright/proxy_auth.js
|
||||
kill `cat LPD.pid` `cat PROXY.id`
|
||||
|
||||
|
||||
@@ -1261,15 +1261,21 @@ pub const Transfer = struct {
|
||||
|
||||
fn detectAuthChallenge(transfer: *Transfer, conn: *const http.Connection) void {
|
||||
const status = conn.getResponseCode() catch return;
|
||||
if (status != 401 and status != 407) {
|
||||
const connect_status = conn.getConnectCode() catch return;
|
||||
|
||||
if (status != 401 and status != 407 and connect_status != 401 and connect_status != 407) {
|
||||
transfer._auth_challenge = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (conn.getResponseHeader("WWW-Authenticate", 0)) |hdr| {
|
||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .server, hdr.value) catch null;
|
||||
} else if (conn.getConnectHeader("WWW-Authenticate", 0)) |hdr| {
|
||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .server, hdr.value) catch null;
|
||||
} else if (conn.getResponseHeader("Proxy-Authenticate", 0)) |hdr| {
|
||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .proxy, hdr.value) catch null;
|
||||
} else if (conn.getConnectHeader("Proxy-Authenticate", 0)) |hdr| {
|
||||
transfer._auth_challenge = http.AuthChallenge.parse(status, .proxy, hdr.value) catch null;
|
||||
} else {
|
||||
transfer._auth_challenge = .{ .status = status, .source = null, .scheme = null, .realm = null };
|
||||
}
|
||||
|
||||
@@ -389,6 +389,15 @@ pub const Connection = struct {
|
||||
return url;
|
||||
}
|
||||
|
||||
pub fn getConnectCode(self: *const Connection) !u16 {
|
||||
var status: c_long = undefined;
|
||||
try libcurl.curl_easy_getinfo(self._easy, .connect_code, &status);
|
||||
if (status < 0 or status > std.math.maxInt(u16)) {
|
||||
return 0;
|
||||
}
|
||||
return @intCast(status);
|
||||
}
|
||||
|
||||
pub fn getResponseCode(self: *const Connection) !u16 {
|
||||
var status: c_long = undefined;
|
||||
try libcurl.curl_easy_getinfo(self._easy, .response_code, &status);
|
||||
@@ -404,6 +413,24 @@ pub const Connection = struct {
|
||||
return @intCast(count);
|
||||
}
|
||||
|
||||
pub fn getConnectHeader(self: *const Connection, name: [:0]const u8, index: usize) ?HeaderValue {
|
||||
var hdr: ?*libcurl.CurlHeader = null;
|
||||
libcurl.curl_easy_header(self._easy, name, index, .connect, -1, &hdr) catch |err| {
|
||||
// ErrorHeader includes OutOfMemory — rare but real errors from curl internals.
|
||||
// Logged and returned as null since callers don't expect errors.
|
||||
log.err(.http, "get response header", .{
|
||||
.name = name,
|
||||
.err = err,
|
||||
});
|
||||
return null;
|
||||
};
|
||||
const h = hdr orelse return null;
|
||||
return .{
|
||||
.amount = h.amount,
|
||||
.value = std.mem.span(h.value),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getResponseHeader(self: *const Connection, name: [:0]const u8, index: usize) ?HeaderValue {
|
||||
var hdr: ?*libcurl.CurlHeader = null;
|
||||
libcurl.curl_easy_header(self._easy, name, index, .header, -1, &hdr) catch |err| {
|
||||
|
||||
@@ -178,6 +178,7 @@ pub const CurlInfo = enum(c.CURLINFO) {
|
||||
private = c.CURLINFO_PRIVATE,
|
||||
redirect_count = c.CURLINFO_REDIRECT_COUNT,
|
||||
response_code = c.CURLINFO_RESPONSE_CODE,
|
||||
connect_code = c.CURLINFO_HTTP_CONNECTCODE,
|
||||
};
|
||||
|
||||
pub const Error = error{
|
||||
@@ -662,6 +663,7 @@ pub fn curl_easy_getinfo(easy: *Curl, comptime info: CurlInfo, out: anytype) Err
|
||||
break :blk c.curl_easy_getinfo(easy, inf, p);
|
||||
},
|
||||
.response_code,
|
||||
.connect_code,
|
||||
.redirect_count,
|
||||
=> blk: {
|
||||
const p: *c_long = out;
|
||||
|
||||
Reference in New Issue
Block a user