Skip to content

Commit 7b46fe9

Browse files
authored
Merge pull request #848 from lightpanda-io/fix_insecure_forward_proxy
Fix non-tls forward-proxy
2 parents afc8c69 + 38bbad6 commit 7b46fe9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/http/client.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub const Client = struct {
236236
return proxy_type == .connect;
237237
}
238238

239-
fn isSimpleProxy(self: *const Client) bool {
239+
fn isForwardProxy(self: *const Client) bool {
240240
const proxy_type = self.proxy_type orelse return false;
241241
return proxy_type == .forward;
242242
}
@@ -711,7 +711,7 @@ pub const Request = struct {
711711
}
712712
}
713713
}
714-
if (self._request_secure and !self._proxy_secure) {
714+
if (self._request_secure and !self._proxy_secure and !self._client.isForwardProxy()) {
715715
self._connection.?.tls = .{
716716
.blocking = try tls.client(std.net.Stream{ .handle = socket }, tls_config),
717717
};
@@ -851,7 +851,7 @@ pub const Request = struct {
851851
try self.headers.append(arena, .{ .name = "User-Agent", .value = "Lightpanda/1.0" });
852852
try self.headers.append(arena, .{ .name = "Accept", .value = "*/*" });
853853

854-
if (self._client.isSimpleProxy()) {
854+
if (self._client.isForwardProxy()) {
855855
if (self._client.proxy_auth) |proxy_auth| {
856856
try self.headers.append(arena, .{ .name = "Proxy-Authorization", .value = proxy_auth });
857857
}
@@ -934,7 +934,7 @@ pub const Request = struct {
934934
}
935935

936936
// A simple http proxy to an https destination is made into tls by the proxy, we see it as a plain connection
937-
const expect_tls = self._proxy_secure or (self._request_secure and !self._client.isSimpleProxy());
937+
const expect_tls = self._proxy_secure or (self._request_secure and !self._client.isForwardProxy());
938938
return self._client.connection_manager.get(expect_tls, self._connect_host, self._connect_port, blocking);
939939
}
940940

@@ -958,7 +958,7 @@ pub const Request = struct {
958958
}
959959

960960
fn buildHeader(self: *Request) ![]const u8 {
961-
const proxied = self._client.isSimpleProxy();
961+
const proxied = self._client.isForwardProxy();
962962

963963
const buf = self._state.header_buf;
964964
var fbs = std.io.fixedBufferStream(buf);

0 commit comments

Comments
 (0)