aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener/Net
diff options
context:
space:
mode:
Diffstat (limited to 'SocketHttpListener/Net')
-rw-r--r--SocketHttpListener/Net/ChunkStream.cs15
-rw-r--r--SocketHttpListener/Net/ChunkedInputStream.cs4
-rw-r--r--SocketHttpListener/Net/HttpConnection.cs32
-rw-r--r--SocketHttpListener/Net/HttpEndPointListener.cs8
-rw-r--r--SocketHttpListener/Net/HttpListener.cs23
-rw-r--r--SocketHttpListener/Net/HttpListenerBasicIdentity.cs29
-rw-r--r--SocketHttpListener/Net/HttpListenerContext.cs16
-rw-r--r--SocketHttpListener/Net/HttpListenerPrefixCollection.cs15
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.Managed.cs4
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.cs27
-rw-r--r--SocketHttpListener/Net/HttpRequestStream.cs18
-rw-r--r--SocketHttpListener/Net/HttpResponseStream.cs18
-rw-r--r--SocketHttpListener/Net/HttpStreamAsyncResult.cs5
-rw-r--r--SocketHttpListener/Net/ListenerPrefix.cs24
14 files changed, 56 insertions, 182 deletions
diff --git a/SocketHttpListener/Net/ChunkStream.cs b/SocketHttpListener/Net/ChunkStream.cs
index b9b5edb38..4bf3a6dea 100644
--- a/SocketHttpListener/Net/ChunkStream.cs
+++ b/SocketHttpListener/Net/ChunkStream.cs
@@ -180,10 +180,7 @@ namespace SocketHttpListener.Net
InternalWrite(buffer, ref offset, size);
}
- public bool WantMore
- {
- get { return (_chunkRead != _chunkSize || _chunkSize != 0 || _state != State.None); }
- }
+ public bool WantMore => (_chunkRead != _chunkSize || _chunkSize != 0 || _state != State.None);
public bool DataAvailable
{
@@ -202,15 +199,9 @@ namespace SocketHttpListener.Net
}
}
- public int TotalDataSize
- {
- get { return _totalWritten; }
- }
+ public int TotalDataSize => _totalWritten;
- public int ChunkLeft
- {
- get { return _chunkSize - _chunkRead; }
- }
+ public int ChunkLeft => _chunkSize - _chunkRead;
private State ReadBody(byte[] buffer, ref int offset, int size)
{
diff --git a/SocketHttpListener/Net/ChunkedInputStream.cs b/SocketHttpListener/Net/ChunkedInputStream.cs
index e74c64e54..cdf7ac649 100644
--- a/SocketHttpListener/Net/ChunkedInputStream.cs
+++ b/SocketHttpListener/Net/ChunkedInputStream.cs
@@ -67,8 +67,8 @@ namespace SocketHttpListener.Net
public ChunkStream Decoder
{
- get { return _decoder; }
- set { _decoder = value; }
+ get => _decoder;
+ set => _decoder = value;
}
protected override int ReadCore(byte[] buffer, int offset, int count)
diff --git a/SocketHttpListener/Net/HttpConnection.cs b/SocketHttpListener/Net/HttpConnection.cs
index 86f9dc635..f6db5f0b2 100644
--- a/SocketHttpListener/Net/HttpConnection.cs
+++ b/SocketHttpListener/Net/HttpConnection.cs
@@ -89,13 +89,7 @@ namespace SocketHttpListener.Net
}
}
- public Stream Stream
- {
- get
- {
- return _stream;
- }
- }
+ public Stream Stream => _stream;
public async Task Init()
{
@@ -131,15 +125,9 @@ namespace SocketHttpListener.Net
_context = new HttpListenerContext(this, _textEncoding);
}
- public bool IsClosed
- {
- get { return (_socket == null); }
- }
+ public bool IsClosed => (_socket == null);
- public int Reuses
- {
- get { return _reuses; }
- }
+ public int Reuses => _reuses;
public IPEndPoint LocalEndPoint
{
@@ -153,20 +141,14 @@ namespace SocketHttpListener.Net
}
}
- public IPEndPoint RemoteEndPoint
- {
- get { return _socket.RemoteEndPoint as IPEndPoint; }
- }
+ public IPEndPoint RemoteEndPoint => _socket.RemoteEndPoint as IPEndPoint;
- public bool IsSecure
- {
- get { return secure; }
- }
+ public bool IsSecure => secure;
public ListenerPrefix Prefix
{
- get { return _prefix; }
- set { _prefix = value; }
+ get => _prefix;
+ set => _prefix = value;
}
private void OnTimeout(object unused)
diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs
index ee6ddaa84..0f1ce696f 100644
--- a/SocketHttpListener/Net/HttpEndPointListener.cs
+++ b/SocketHttpListener/Net/HttpEndPointListener.cs
@@ -58,13 +58,7 @@ namespace SocketHttpListener.Net
CreateSocket();
}
- internal HttpListener Listener
- {
- get
- {
- return _listener;
- }
- }
+ internal HttpListener Listener => _listener;
private void CreateSocket()
{
diff --git a/SocketHttpListener/Net/HttpListener.cs b/SocketHttpListener/Net/HttpListener.cs
index 4e2239a1a..8ec6b89aa 100644
--- a/SocketHttpListener/Net/HttpListener.cs
+++ b/SocketHttpListener/Net/HttpListener.cs
@@ -70,7 +70,7 @@ namespace SocketHttpListener.Net
// TODO: Digest, NTLM and Negotiate require ControlPrincipal
public AuthenticationSchemes AuthenticationSchemes
{
- get { return auth_schemes; }
+ get => auth_schemes;
set
{
CheckDisposed();
@@ -80,7 +80,7 @@ namespace SocketHttpListener.Net
public AuthenticationSchemeSelector AuthenticationSchemeSelectorDelegate
{
- get { return auth_selector; }
+ get => auth_selector;
set
{
CheckDisposed();
@@ -88,15 +88,9 @@ namespace SocketHttpListener.Net
}
}
- public bool IsListening
- {
- get { return listening; }
- }
+ public bool IsListening => listening;
- public static bool IsSupported
- {
- get { return true; }
- }
+ public static bool IsSupported => true;
public HttpListenerPrefixCollection Prefixes
{
@@ -110,7 +104,7 @@ namespace SocketHttpListener.Net
// TODO: use this
public string Realm
{
- get { return realm; }
+ get => realm;
set
{
CheckDisposed();
@@ -120,7 +114,7 @@ namespace SocketHttpListener.Net
public bool UnsafeConnectionNtlmAuthentication
{
- get { return unsafe_ntlm_auth; }
+ get => unsafe_ntlm_auth;
set
{
CheckDisposed();
@@ -142,10 +136,7 @@ namespace SocketHttpListener.Net
// }
//}
- internal X509Certificate Certificate
- {
- get { return _certificate; }
- }
+ internal X509Certificate Certificate => _certificate;
public void Abort()
{
diff --git a/SocketHttpListener/Net/HttpListenerBasicIdentity.cs b/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
index 391fc931e..5f6ec44b9 100644
--- a/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
+++ b/SocketHttpListener/Net/HttpListenerBasicIdentity.cs
@@ -12,10 +12,7 @@ namespace SocketHttpListener.Net
this.password = password;
}
- public virtual string Password
- {
- get { return password; }
- }
+ public virtual string Password => password;
}
public class GenericIdentity : IIdentity
@@ -43,28 +40,10 @@ namespace SocketHttpListener.Net
m_type = type;
}
- public virtual string Name
- {
- get
- {
- return m_name;
- }
- }
+ public virtual string Name => m_name;
- public virtual string AuthenticationType
- {
- get
- {
- return m_type;
- }
- }
+ public virtual string AuthenticationType => m_type;
- public virtual bool IsAuthenticated
- {
- get
- {
- return !m_name.Equals("");
- }
- }
+ public virtual bool IsAuthenticated => !m_name.Equals("");
}
}
diff --git a/SocketHttpListener/Net/HttpListenerContext.cs b/SocketHttpListener/Net/HttpListenerContext.cs
index 0bb31ef3e..8045299c6 100644
--- a/SocketHttpListener/Net/HttpListenerContext.cs
+++ b/SocketHttpListener/Net/HttpListenerContext.cs
@@ -18,13 +18,7 @@ namespace SocketHttpListener.Net
// This can be used to cache the results of HttpListener.AuthenticationSchemeSelectorDelegate.
internal AuthenticationSchemes AuthenticationSchemes { get; set; }
- public HttpListenerResponse Response
- {
- get
- {
- return _response;
- }
- }
+ public HttpListenerResponse Response => _response;
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol)
{
@@ -62,13 +56,7 @@ namespace SocketHttpListener.Net
}
}
- public virtual IIdentity Identity
- {
- get
- {
- return m_identity;
- }
- }
+ public virtual IIdentity Identity => m_identity;
public virtual bool IsInRole(string role)
{
diff --git a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs b/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
index f0e496a5a..97dc6797c 100644
--- a/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
+++ b/SocketHttpListener/Net/HttpListenerPrefixCollection.cs
@@ -18,20 +18,11 @@ namespace SocketHttpListener.Net
this.listener = listener;
}
- public int Count
- {
- get { return prefixes.Count; }
- }
+ public int Count => prefixes.Count;
- public bool IsReadOnly
- {
- get { return false; }
- }
+ public bool IsReadOnly => false;
- public bool IsSynchronized
- {
- get { return false; }
- }
+ public bool IsSynchronized => false;
public void Add(string uriPrefix)
{
diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
index 9097a85f5..198cdcf76 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
@@ -38,7 +38,7 @@ namespace SocketHttpListener.Net
public Version ProtocolVersion
{
- get { return _version; }
+ get => _version;
set
{
CheckDisposed();
@@ -57,7 +57,7 @@ namespace SocketHttpListener.Net
public int StatusCode
{
- get { return _statusCode; }
+ get => _statusCode;
set
{
CheckDisposed();
diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs
index f9455db72..a32aca043 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.cs
@@ -15,16 +15,13 @@ namespace SocketHttpListener.Net
private string _statusDescription;
private WebHeaderCollection _webHeaders = new WebHeaderCollection();
- public WebHeaderCollection Headers
- {
- get { return _webHeaders; }
- }
+ public WebHeaderCollection Headers => _webHeaders;
public Encoding ContentEncoding { get; set; }
public string ContentType
{
- get { return Headers["Content-Type"]; }
+ get => Headers["Content-Type"];
set
{
CheckDisposed();
@@ -39,13 +36,13 @@ namespace SocketHttpListener.Net
}
}
- private HttpListenerContext HttpListenerContext { get { return _httpContext; } }
+ private HttpListenerContext HttpListenerContext => _httpContext;
- private HttpListenerRequest HttpListenerRequest { get { return HttpListenerContext.Request; } }
+ private HttpListenerRequest HttpListenerRequest => HttpListenerContext.Request;
internal EntitySendFormat EntitySendFormat
{
- get { return (EntitySendFormat)_boundaryType; }
+ get => (EntitySendFormat)_boundaryType;
set
{
CheckDisposed();
@@ -64,8 +61,8 @@ namespace SocketHttpListener.Net
public bool SendChunked
{
- get { return EntitySendFormat == EntitySendFormat.Chunked; }
- set { EntitySendFormat = value ? EntitySendFormat.Chunked : EntitySendFormat.ContentLength; }
+ get => EntitySendFormat == EntitySendFormat.Chunked;
+ set => EntitySendFormat = value ? EntitySendFormat.Chunked : EntitySendFormat.ContentLength;
}
// We MUST NOT send message-body when we send responses with these Status codes
@@ -85,7 +82,7 @@ namespace SocketHttpListener.Net
public long ContentLength64
{
- get { return _contentLength; }
+ get => _contentLength;
set
{
CheckDisposed();
@@ -104,13 +101,13 @@ namespace SocketHttpListener.Net
public CookieCollection Cookies
{
- get { return _cookies ?? (_cookies = new CookieCollection()); }
- set { _cookies = value; }
+ get => _cookies ?? (_cookies = new CookieCollection());
+ set => _cookies = value;
}
public bool KeepAlive
{
- get { return _keepAlive; }
+ get => _keepAlive;
set
{
CheckDisposed();
@@ -130,7 +127,7 @@ namespace SocketHttpListener.Net
public string RedirectLocation
{
- get { return Headers["Location"]; }
+ get => Headers["Location"];
set
{
// note that this doesn't set the status code to a redirect one
diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs
index ec3ca8d33..1c554df20 100644
--- a/SocketHttpListener/Net/HttpRequestStream.cs
+++ b/SocketHttpListener/Net/HttpRequestStream.cs
@@ -84,25 +84,13 @@ namespace SocketHttpListener.Net
public override void Flush() { }
public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
- public override long Length
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override long Length => throw new NotImplementedException();
public override long Position
{
- get
- {
- throw new NotImplementedException();
- }
+ get => throw new NotImplementedException();
- set
- {
- throw new NotImplementedException();
- }
+ set => throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
diff --git a/SocketHttpListener/Net/HttpResponseStream.cs b/SocketHttpListener/Net/HttpResponseStream.cs
index bfe0199de..085c2ad0c 100644
--- a/SocketHttpListener/Net/HttpResponseStream.cs
+++ b/SocketHttpListener/Net/HttpResponseStream.cs
@@ -17,25 +17,13 @@ namespace SocketHttpListener.Net
public override void Flush() { }
public override Task FlushAsync(CancellationToken cancellationToken) => Task.CompletedTask;
- public override long Length
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public override long Length => throw new NotImplementedException();
public override long Position
{
- get
- {
- throw new NotImplementedException();
- }
+ get => throw new NotImplementedException();
- set
- {
- throw new NotImplementedException();
- }
+ set => throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
diff --git a/SocketHttpListener/Net/HttpStreamAsyncResult.cs b/SocketHttpListener/Net/HttpStreamAsyncResult.cs
index d96988fce..46944c624 100644
--- a/SocketHttpListener/Net/HttpStreamAsyncResult.cs
+++ b/SocketHttpListener/Net/HttpStreamAsyncResult.cs
@@ -47,10 +47,7 @@ namespace SocketHttpListener.Net
}
}
- public object AsyncState
- {
- get { return _state; }
- }
+ public object AsyncState => _state;
public WaitHandle AsyncWaitHandle
{
diff --git a/SocketHttpListener/Net/ListenerPrefix.cs b/SocketHttpListener/Net/ListenerPrefix.cs
index b29cc5c6d..3e78752fd 100644
--- a/SocketHttpListener/Net/ListenerPrefix.cs
+++ b/SocketHttpListener/Net/ListenerPrefix.cs
@@ -26,28 +26,16 @@ namespace SocketHttpListener.Net
public IPAddress[] Addresses
{
- get { return _addresses; }
- set { _addresses = value; }
- }
- public bool Secure
- {
- get { return _secure; }
+ get => _addresses;
+ set => _addresses = value;
}
+ public bool Secure => _secure;
- public string Host
- {
- get { return _host; }
- }
+ public string Host => _host;
- public int Port
- {
- get { return _port; }
- }
+ public int Port => _port;
- public string Path
- {
- get { return _path; }
- }
+ public string Path => _path;
// Equals and GetHashCode are required to detect duplicates in HttpListenerPrefixCollection.
public override bool Equals(object o)