further correct handling of closed connections (throwing NullReference)
ln.build build job pending
ln.build build job pending
parent
cf6bf86a36
commit
4f1ee0a63c
|
@ -96,6 +96,10 @@ namespace ln.http
|
|||
void ReadRequestLine()
|
||||
{
|
||||
string requestLine = connectionReader.ReadLine();
|
||||
|
||||
if (requestLine == null)
|
||||
throw new ConnectionClosedException("UnbufferedStreamReader.ReadLine() returned null");
|
||||
|
||||
string[] requestTokens = requestLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (requestTokens.Length != 3)
|
||||
|
|
|
@ -12,6 +12,8 @@ using ln.type;
|
|||
using System.IO;
|
||||
using ln.logging;
|
||||
using ln.http.listener;
|
||||
using ln.http.exceptions;
|
||||
|
||||
namespace ln.http.connections
|
||||
{
|
||||
public abstract class Connection : IDisposable
|
||||
|
@ -34,6 +36,9 @@ namespace ln.http.connections
|
|||
{
|
||||
return new HttpRequest(httpServer, GetStream(), Listener.LocalEndpoint, new Endpoint(RemoteHost, RemotePort));
|
||||
} catch (IOException)
|
||||
{
|
||||
return null;
|
||||
} catch (ConnectionClosedException)
|
||||
{
|
||||
return null;
|
||||
} catch (Exception e)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace ln.http.exceptions
|
||||
{
|
||||
|
||||
public class ConnectionClosedException : Exception
|
||||
{
|
||||
public ConnectionClosedException(string message) : base(message) { }
|
||||
|
||||
public ConnectionClosedException(){ }
|
||||
}
|
||||
|
||||
}
|
|
@ -3,14 +3,12 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.1.1</Version>
|
||||
<Version>0.1.2</Version>
|
||||
<Authors>Harald Wolff-Thobaben</Authors>
|
||||
<Company>l--n.de</Company>
|
||||
<Description />
|
||||
<Copyright>(c) 2020 Harald Wolff-Thobaben</Copyright>
|
||||
<PackageTags>http server</PackageTags>
|
||||
<AssemblyVersion>0.0.1.0</AssemblyVersion>
|
||||
<FileVersion>0.0.1.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in New Issue