further correct handling of closed connections (throwing NullReference)
ln.build build job pending

master
Harald Wolff 2020-11-29 14:20:51 +01:00
parent cf6bf86a36
commit 4f1ee0a63c
4 changed files with 23 additions and 3 deletions

View File

@ -96,6 +96,10 @@ namespace ln.http
void ReadRequestLine() void ReadRequestLine()
{ {
string requestLine = connectionReader.ReadLine(); string requestLine = connectionReader.ReadLine();
if (requestLine == null)
throw new ConnectionClosedException("UnbufferedStreamReader.ReadLine() returned null");
string[] requestTokens = requestLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries); string[] requestTokens = requestLine.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
if (requestTokens.Length != 3) if (requestTokens.Length != 3)

View File

@ -12,6 +12,8 @@ using ln.type;
using System.IO; using System.IO;
using ln.logging; using ln.logging;
using ln.http.listener; using ln.http.listener;
using ln.http.exceptions;
namespace ln.http.connections namespace ln.http.connections
{ {
public abstract class Connection : IDisposable public abstract class Connection : IDisposable
@ -34,6 +36,9 @@ namespace ln.http.connections
{ {
return new HttpRequest(httpServer, GetStream(), Listener.LocalEndpoint, new Endpoint(RemoteHost, RemotePort)); return new HttpRequest(httpServer, GetStream(), Listener.LocalEndpoint, new Endpoint(RemoteHost, RemotePort));
} catch (IOException) } catch (IOException)
{
return null;
} catch (ConnectionClosedException)
{ {
return null; return null;
} catch (Exception e) } catch (Exception e)

View File

@ -0,0 +1,13 @@
using System;
namespace ln.http.exceptions
{
public class ConnectionClosedException : Exception
{
public ConnectionClosedException(string message) : base(message) { }
public ConnectionClosedException(){ }
}
}

View File

@ -3,14 +3,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.1.1</Version> <Version>0.1.2</Version>
<Authors>Harald Wolff-Thobaben</Authors> <Authors>Harald Wolff-Thobaben</Authors>
<Company>l--n.de</Company> <Company>l--n.de</Company>
<Description /> <Description />
<Copyright>(c) 2020 Harald Wolff-Thobaben</Copyright> <Copyright>(c) 2020 Harald Wolff-Thobaben</Copyright>
<PackageTags>http server</PackageTags> <PackageTags>http server</PackageTags>
<AssemblyVersion>0.0.1.0</AssemblyVersion>
<FileVersion>0.0.1.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>