justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

Tunnel agent exception error #744

Open q349980363 opened 4 years ago

q349980363 commented 4 years ago

I'm using "Titanium-Web-Proxy" as Nintendo's switch console download accelerator. I use tunnel agents to do this function

var proxyServer = new ProxyServer();
var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, false) {
};
explicitEndPoint.BeforeTunnelConnectRequest += ExplicitEndPoint_BeforeTunnelConnectRequest;
proxyServer.AddEndPoint(explicitEndPoint);
proxyServer.Start();
async private static Task ExplicitEndPoint_BeforeTunnelConnectRequest(object sender, Titanium.Web.Proxy.EventArguments.TunnelConnectSessionEventArgs e) {
            e.DecryptSsl = false;
}

But there was an error downloading the game, and I used Fiddler without the problem

image Use "Titanium-Web-Proxy" as a proxy game opportunity to prompt this error

2005-0140

With Fiddler, there's no such error, that you can download the game normally.

q349980363 commented 4 years ago

image This is me using Fiddler as an upstream agent.

image This is my direct use of Fiddler as an agent.

image

I don't know if it's helpful.

q349980363 commented 4 years ago

Titanium-Web-Proxy-master\src\Titanium.Web.Proxy\ExplicitClientHandler.cs


                    // write back successful CONNECT response
                    var response = ConnectResponse.CreateSuccessfulConnectResponse(connectRequest.HttpVersion);

                    // Set ContentLength explicitly to properly handle HTTP 1.0
                    response.ContentLength = -1;
                    response.Headers.FixProxyHeaders();
                    connectArgs.HttpClient.Response = response;

                    await clientStream.WriteResponseAsync(response, cancellationToken);

I found the wrong cause. I fixed this problem the way I got down there.

response.ContentLength = 0;->response.ContentLength = -1;

honfika commented 4 years ago

This line was added by @bjowes : https://github.com/justcoding121/Titanium-Web-Proxy/commit/1d06ec32fc3ac16a9be14aad19196be586abb6d4 and https://github.com/justcoding121/Titanium-Web-Proxy/commit/30870882fdccb4837ebf903647aab8abd05d524e

Is it really needed for HTTP/1.0?

q349980363 commented 4 years ago

This line was added by @bjowes : 1d06ec3 and 3087088

Is it really needed for HTTP/1.0?

Now should no longer exist http 1.0

Should support be provided as an option?

justcoding121 commented 3 years ago

Maybe we should add a condition to check if it's HTTP/1.0 in connect request headline and use 0 or -1.