diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index 55e5b002..2d8f89a1 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -396,22 +396,35 @@ namespace MinecraftClient.Protocol { string postResult = null; int statusCode = 520; + Exception exception = null; AutoTimeout.Perform(() => { - TcpClient client = ProxyHandler.newTcpClient(host, 443, true); - SslStream stream = new SslStream(client.GetStream()); - stream.AuthenticateAsClient(host); - stream.Write(Encoding.ASCII.GetBytes(String.Join("\r\n", headers.ToArray()))); - System.IO.StreamReader sr = new System.IO.StreamReader(stream); - string raw_result = sr.ReadToEnd(); - if (raw_result.StartsWith("HTTP/1.1")) + try { - postResult = raw_result.Substring(raw_result.IndexOf("\r\n\r\n") + 4); - statusCode = Settings.str2int(raw_result.Split(' ')[1]); + TcpClient client = ProxyHandler.newTcpClient(host, 443, true); + SslStream stream = new SslStream(client.GetStream()); + stream.AuthenticateAsClient(host); + stream.Write(Encoding.ASCII.GetBytes(String.Join("\r\n", headers.ToArray()))); + System.IO.StreamReader sr = new System.IO.StreamReader(stream); + string raw_result = sr.ReadToEnd(); + if (raw_result.StartsWith("HTTP/1.1")) + { + postResult = raw_result.Substring(raw_result.IndexOf("\r\n\r\n") + 4); + statusCode = Settings.str2int(raw_result.Split(' ')[1]); + } + else statusCode = 520; //Web server is returning an unknown error + } + catch (Exception e) + { + if (!(e is System.Threading.ThreadAbortException)) + { + exception = e; + } } - else statusCode = 520; //Web server is returning an unknown error }, TimeSpan.FromSeconds(30)); result = postResult; + if (exception != null) + throw exception; return statusCode; }