mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-30 17:18:57 +00:00
http: add connect code into auth challenge detection
This commit is contained in:
@@ -1261,7 +1261,9 @@ pub const Transfer = struct {
|
|||||||
|
|
||||||
fn detectAuthChallenge(transfer: *Transfer, conn: *const http.Connection) void {
|
fn detectAuthChallenge(transfer: *Transfer, conn: *const http.Connection) void {
|
||||||
const status = conn.getResponseCode() catch return;
|
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;
|
transfer._auth_challenge = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,6 +389,15 @@ pub const Connection = struct {
|
|||||||
return url;
|
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 {
|
pub fn getResponseCode(self: *const Connection) !u16 {
|
||||||
var status: c_long = undefined;
|
var status: c_long = undefined;
|
||||||
try libcurl.curl_easy_getinfo(self._easy, .response_code, &status);
|
try libcurl.curl_easy_getinfo(self._easy, .response_code, &status);
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ pub const CurlInfo = enum(c.CURLINFO) {
|
|||||||
private = c.CURLINFO_PRIVATE,
|
private = c.CURLINFO_PRIVATE,
|
||||||
redirect_count = c.CURLINFO_REDIRECT_COUNT,
|
redirect_count = c.CURLINFO_REDIRECT_COUNT,
|
||||||
response_code = c.CURLINFO_RESPONSE_CODE,
|
response_code = c.CURLINFO_RESPONSE_CODE,
|
||||||
|
connect_code = c.CURLINFO_HTTP_CONNECTCODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Error = error{
|
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);
|
break :blk c.curl_easy_getinfo(easy, inf, p);
|
||||||
},
|
},
|
||||||
.response_code,
|
.response_code,
|
||||||
|
.connect_code,
|
||||||
.redirect_count,
|
.redirect_count,
|
||||||
=> blk: {
|
=> blk: {
|
||||||
const p: *c_long = out;
|
const p: *c_long = out;
|
||||||
|
|||||||
Reference in New Issue
Block a user