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

Adds possibility to allow forwarded websocket requests for HttpServer #454

Open
wants to merge 1 commit into
base: master
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
2 changes: 1 addition & 1 deletion websocket-sharp/Net/EndPointListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ internal bool TrySearchHttpListener (Uri uri, out HttpListener listener)
continue;
}

if (pref.Port != port)
if (pref.Port != port && !_prefixes[pref].AllowForwardedRequest)
continue;

var prefPath = pref.Path;
Expand Down
24 changes: 24 additions & 0 deletions websocket-sharp/Net/HttpListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public sealed class HttpListener : IDisposable
{
#region Private Fields

private bool _allowForwardedRequest;
private AuthenticationSchemes _authSchemes;
private Func<HttpListenerRequest, AuthenticationSchemes> _authSchemeSelector;
private string _certFolderPath;
Expand Down Expand Up @@ -144,6 +145,29 @@ internal bool ReuseAddress {

#region Public Properties

/// <summary>
/// Gets or sets a value indicating whether the server accepts every
/// handshake request without checking the request URI.
/// </summary>
/// <remarks>
/// The set operation does nothing if the server has already started or
/// it is shutting down.
/// </remarks>
/// <value>
/// <para>
/// <c>true</c> if the server accepts every handshake request without
/// checking the request URI; otherwise, <c>false</c>.
/// </para>
/// <para>
/// The default value is <c>false</c>.
/// </para>
/// </value>
public bool AllowForwardedRequest
{
get { return _allowForwardedRequest; }
set { _allowForwardedRequest = value; }
}

/// <summary>
/// Gets or sets the scheme used to authenticate the clients.
/// </summary>
Expand Down
23 changes: 23 additions & 0 deletions websocket-sharp/Server/HttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,29 @@ public System.Net.IPAddress Address {
}
}

/// <summary>
/// Gets or sets a value indicating whether the server accepts every
/// handshake request without checking the request URI.
/// </summary>
/// <remarks>
/// The set operation does nothing if the server has already started or
/// it is shutting down.
/// </remarks>
/// <value>
/// <para>
/// <c>true</c> if the server accepts every handshake request without
/// checking the request URI; otherwise, <c>false</c>.
/// </para>
/// <para>
/// The default value is <c>false</c>.
/// </para>
/// </value>
public bool AllowForwardedRequest
{
get { return _listener.AllowForwardedRequest; }
set { _listener.AllowForwardedRequest = value; }
}

/// <summary>
/// Gets or sets the scheme used to authenticate the clients.
/// </summary>
Expand Down