Browse Source

Fix a bug that the callback will be invoked twice if http proxy request failed. (#751)

tags/3.3.2
Noisyfox Syrone Wong 8 years ago
parent
commit
4acae9de9b
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      shadowsocks-csharp/Proxy/HttpProxy.cs

+ 6
- 4
shadowsocks-csharp/Proxy/HttpProxy.cs View File

@@ -145,12 +145,15 @@ namespace Shadowsocks.Proxy

private void OnFinish(byte[] lastBytes, int index, int length, object state)
{
// TODO: save last bytes
var st = (FakeAsyncResult)state;

if (!_established)
if (st.innerState.ex == null)
{
st.innerState.ex = new Exception(I18N.GetString("Proxy request failed"));
if (!_established)
{
st.innerState.ex = new Exception(I18N.GetString("Proxy request failed"));
}
// TODO: save last bytes
}
st.innerState.Callback?.Invoke(st);
}
@@ -160,7 +163,6 @@ namespace Shadowsocks.Proxy
var st = (FakeAsyncResult) state;

st.innerState.ex = ex;
st.innerState.Callback?.Invoke(st);
}

private static readonly Regex HttpRespondHeaderRegex = new Regex(@"^(HTTP/1\.\d) (\d{3}) (.+)$");


Loading…
Cancel
Save