mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-18 16:06:50 +08:00
Proxy Requests Non-HTTP Do not send CONNECT requests
This commit is contained in:
@@ -189,8 +189,8 @@ class HttpProxyChannelHandler extends ChannelHandler<HttpRequest> {
|
||||
if (httpRequest.method == HttpMethod.connect) {
|
||||
await proxyChannel.write(httpRequest);
|
||||
} else {
|
||||
await HttpClients.connectRequest(hostAndPort, proxyChannel);
|
||||
if (clientChannel.isSsl) {
|
||||
await HttpClients.connectRequest(hostAndPort, proxyChannel);
|
||||
await proxyChannel.secureSocket(channelContext, host: hostAndPort.host);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class HttpRequest extends HttpMessage {
|
||||
String path() {
|
||||
try {
|
||||
var requestPath = Uri.parse(requestUrl).path;
|
||||
return requestPath.isEmpty ? "/" : requestPath;
|
||||
return requestPath.isEmpty ? "" : requestPath;
|
||||
} catch (e) {
|
||||
return "/";
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class HttpClients {
|
||||
HostAndPort connectHost = proxyInfo == null ? hostAndPort : HostAndPort.host(proxyInfo.host, proxyInfo.port!);
|
||||
var channel = await client.connect(connectHost, channelContext);
|
||||
|
||||
if (proxyInfo != null) {
|
||||
if (proxyInfo != null && hostAndPort.isSsl()) {
|
||||
await connectRequest(hostAndPort, channel);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,10 @@ class ProxyHelper {
|
||||
..hostAndPort = hostAndPort;
|
||||
request.processInfo ??= channelContext.processInfo;
|
||||
|
||||
if (request.method == HttpMethod.connect && !request.requestUrl.startsWith("http")) {
|
||||
request.uri = hostAndPort.domain;
|
||||
}
|
||||
|
||||
request.response = HttpResponse(status)
|
||||
..headers.contentType = 'text/plain'
|
||||
..headers.contentLength = message.codeUnits.length
|
||||
|
||||
Reference in New Issue
Block a user