Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an httplistener #2

Open
wants to merge 7 commits into
base: GHfVS
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### New in 0.0.3

* HttpListener

### New in 0.0.2

* Signing key for GHfVS
Expand Down
6 changes: 3 additions & 3 deletions SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Reflection;

[assembly: AssemblyProductAttribute("Rothko")]
[assembly: AssemblyVersionAttribute("0.0.2")]
[assembly: AssemblyFileVersionAttribute("0.0.2")]
[assembly: AssemblyVersionAttribute("0.0.3")]
[assembly: AssemblyFileVersionAttribute("0.0.3")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "0.0.2";
internal const string Version = "0.0.3";
}
}
Binary file modified src/GlobalSuppressions.cs
Binary file not shown.
1 change: 1 addition & 0 deletions src/Infrastructure/IOperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface IOperatingSystem
IEnvironment Environment { get; }
IFileFacade File { get; }
IMemoryMappedFileFactory MemoryMappedFiles { get; }
INetFactory Net { get; }
IProcessLocator ProcessLocator { get; }
IProcessStarter ProcessStarter { get; }
IRegistry Registry { get; }
Expand Down
61 changes: 61 additions & 0 deletions src/Net/HttpListenerContextWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Net;
using System.Net.WebSockets;
using System.Security.Principal;
using System.Threading.Tasks;

namespace Rothko
{
public class HttpListenerContextWrapper : IHttpListenerContext, IDisposable
{
readonly HttpListenerContext inner;

public HttpListenerContextWrapper(HttpListenerContext inner)
{
this.inner = inner;
Request = new HttpListenerRequestWrapper(inner.Request);
Response = new HttpListenerResponseWrapper(inner.Response);
}

public IHttpListenerRequest Request { get; }

public IHttpListenerResponse Response { get; }

public IPrincipal User => inner.User;

public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol)
{
return inner.AcceptWebSocketAsync(subProtocol);
}

public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol, TimeSpan keepAliveInterval)
{
return inner.AcceptWebSocketAsync(subProtocol, keepAliveInterval);
}

public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval)
{
return inner.AcceptWebSocketAsync(subProtocol, receiveBufferSize, keepAliveInterval);
}

public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval,
ArraySegment<byte> internalBuffer)
{
return inner.AcceptWebSocketAsync(subProtocol, receiveBufferSize, keepAliveInterval, internalBuffer);
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Response.Dispose();
}
}
}
}
99 changes: 99 additions & 0 deletions src/Net/HttpListenerRequestWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace Rothko
{
public class HttpListenerRequestWrapper : IHttpListenerRequest
{
readonly HttpListenerRequest inner;

public HttpListenerRequestWrapper(HttpListenerRequest inner)
{
this.inner = inner;
}

public IEnumerable<string> AcceptTypes => inner.AcceptTypes;

public int ClientCertificateError => inner.ClientCertificateError;

public Encoding ContentEncoding => inner.ContentEncoding;

public long ContentLength64 => inner.ContentLength64;

public string ContentType => inner.ContentType;

public CookieCollection Cookies => inner.Cookies;

public bool HasEntityBody => inner.HasEntityBody;

public NameValueCollection Headers => inner.Headers;

public string HttpMethod => inner.HttpMethod;

public Stream InputStream => inner.InputStream;

public bool IsAuthenticated => inner.IsAuthenticated;

public bool IsLocal => inner.IsLocal;

public bool IsSecureConnection => inner.IsSecureConnection;

public bool IsWebSocketRequest => inner.IsWebSocketRequest;

public bool KeepAlive => inner.KeepAlive;

public IPEndPoint LocalEndPoint => inner.LocalEndPoint;

public Version ProtocolVersion => inner.ProtocolVersion;

public NameValueCollection QueryString => inner.QueryString;

public string RawUrl => inner.RawUrl;

public IPEndPoint RemoteEndPoint => inner.RemoteEndPoint;

public Guid RequestTraceIdentifier => inner.RequestTraceIdentifier;

public string ServiceName => inner.ServiceName;

public TransportContext TransportContext => inner.TransportContext;

public Uri Url => inner.Url;

public Uri UrlReferrer => inner.UrlReferrer;

public string UserAgent => inner.UserAgent;

public string UserHostAddress => inner.UserHostAddress;

public string UserHostName => inner.UserHostName;

public IEnumerable<string> UserLanguages => inner.UserLanguages;

public IAsyncResult BeginGetClientCertificate(AsyncCallback requestCallback, object state)
{
return inner.BeginGetClientCertificate(requestCallback, state);
}

public X509Certificate2 EndGetClientCertificate(IAsyncResult asyncResult)
{
return inner.EndGetClientCertificate(asyncResult);
}

public X509Certificate2 GetClientCertificate()
{
return inner.GetClientCertificate();
}

public Task<X509Certificate2> GetClientCertificateAsync()
{
return inner.GetClientCertificateAsync();
}
}
}
119 changes: 119 additions & 0 deletions src/Net/HttpListenerResponseWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using System.IO;
using System.Net;
using System.Text;

namespace Rothko
{
public class HttpListenerResponseWrapper : IHttpListenerResponse
{
private HttpListenerResponse inner;

public HttpListenerResponseWrapper(HttpListenerResponse inner)
{
this.inner = inner;
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

public Encoding ContentEncoding
{
get { return inner.ContentEncoding; }
set { inner.ContentEncoding = value; }
}

public long ContentLength64
{
get { return inner.ContentLength64; }
set { inner.ContentLength64 = value; }
}

public string ContentType
{
get { return inner.ContentType; }
set { inner.ContentType = value; }
}

public CookieCollection Cookies
{
get { return inner.Cookies; }
set { inner.Cookies = value; }
}

public WebHeaderCollection Headers
{
get { return inner.Headers; }
set { inner.Headers = value; }
}

public bool KeepAlive
{
get { return inner.KeepAlive; }
set { inner.KeepAlive = value; }
}

public Stream OutputStream => inner.OutputStream;

public Version ProtocolVersion
{
get { return inner.ProtocolVersion; }
set { inner.ProtocolVersion = value; }
}

public string RedirectLocation
{
get { return inner.RedirectLocation; }
set { inner.RedirectLocation = value; }
}

public bool SendChunked
{
get { return inner.SendChunked; }
set { inner.SendChunked = value; }
}

public int StatusCode
{
get { return inner.StatusCode; }
set { inner.StatusCode = value; }
}

public string StatusDescription
{
get { return inner.StatusDescription; }
set { inner.StatusDescription = value; }
}

public void Abort() => inner.Abort();

public void AddHeader(string name, string value) => inner.AddHeader(name, value);

public void AppendCookie(Cookie cookie) => inner.AppendCookie(cookie);

public void AppendHeader(string name, string value) => inner.AppendHeader(name, value);

public void Close() => inner.Close();

public void Close(byte[] responseEntity, bool willBlock) => inner.Close(responseEntity, willBlock);

public void CopyFrom(HttpListenerResponse templateResponse) => inner.CopyFrom(templateResponse);

public void Redirect(string url) => inner.Redirect(url);

public void Redirect(Uri url) => inner.Redirect(url.ToString());

public void SetCookie(Cookie cookie) => inner.SetCookie(cookie);

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
((IDisposable)inner).Dispose();
}
}
}
}
Loading