Modified sendProxyConnectRequest method

This commit is contained in:
sta 2014-08-03 22:04:31 +09:00
parent 62801f0a8e
commit 635d5372a1

View File

@ -1214,7 +1214,7 @@ namespace WebSocketSharp
} }
// As client // As client
private HttpResponse sendProxyConnectRequest () private void sendProxyConnectRequest ()
{ {
var req = HttpRequest.CreateConnectRequest (_uri); var req = HttpRequest.CreateConnectRequest (_uri);
var res = sendHttpRequest (req, 90000); var res = sendHttpRequest (req, 90000);
@ -1231,9 +1231,14 @@ namespace WebSocketSharp
req.Headers["Proxy-Authorization"] = authRes.ToString (); req.Headers["Proxy-Authorization"] = authRes.ToString ();
res = sendHttpRequest (req, 15000); res = sendHttpRequest (req, 15000);
} }
if (res.IsProxyAuthenticationRequired)
throw new WebSocketException ("Proxy authentication is required.");
} }
return res; if (res.StatusCode[0] != '2')
throw new WebSocketException (
"The proxy has failed a connection to the requested host and port.");
} }
// As client // As client
@ -1246,15 +1251,8 @@ namespace WebSocketSharp
_stream = _tcpClient.GetStream (); _stream = _tcpClient.GetStream ();
if (proxy) { if (proxy)
var res = sendProxyConnectRequest (); sendProxyConnectRequest ();
if (res.IsProxyAuthenticationRequired)
throw new WebSocketException ("Proxy authentication is required.");
if (res.StatusCode[0] != '2')
throw new WebSocketException (
"The proxy has failed a connection to the requested host and port.");
}
if (_secure) { if (_secure) {
var sslStream = new SslStream ( var sslStream = new SslStream (