Fixed read timeout issue.

master^2 v1.1.1
flash 8 months ago
parent 0e1fb36721
commit ad80ef21c8
  1. 16
      Hamakaze/HttpConnection.cs

@ -13,6 +13,9 @@ namespace Hamakaze {
private Socket Socket { get; }
private NetworkStream NetworkStream { get; }
private SslStream SslStream { get; }
public string Host { get; }
public bool IsSecure { get; }
@ -39,19 +42,19 @@ namespace Hamakaze {
};
Socket.Connect(endPoint);
Stream stream = new NetworkStream(Socket, true);
NetworkStream = new NetworkStream(Socket, true);
if(IsSecure) {
SslStream sslStream = new SslStream(stream, false, (s, ce, ch, e) => e == SslPolicyErrors.None, null);
Stream = sslStream;
sslStream.AuthenticateAsClient(
SslStream = new SslStream(NetworkStream, false, (s, ce, ch, e) => e == SslPolicyErrors.None, null);
Stream = SslStream;
SslStream.AuthenticateAsClient(
Host,
null,
SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13,
true
);
} else
Stream = stream;
Stream = NetworkStream;
}
public void MarkUsed() {
@ -73,6 +76,9 @@ namespace Hamakaze {
throw new HttpConnectionAlreadyUpgradedException();
HasUpgraded = true;
NetworkStream.ReadTimeout = -1;
SslStream.ReadTimeout = -1;
return new WsConnection(Stream);
}

Loading…
Cancel
Save