Compare commits

...

3 commits

3 changed files with 13 additions and 5 deletions

View file

@ -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);
}

View file

@ -5,3 +5,5 @@ Shoddy custom HTTP client, currently targeting C#.
System.Http.HttpClient is annoying cause it forces async on you and they've conveniently deprecated everything else.
Not really intended for use by anyone other than myself.
![](logo.png)

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB