Renamed ListenerAsyncResult class to HttpListenerAsyncResult class
This commit is contained in:
parent
9c79e28f22
commit
298ed9210e
@ -78,7 +78,7 @@ namespace WebSocketSharp.Net
|
|||||||
private string _realm;
|
private string _realm;
|
||||||
private bool _reuseAddress;
|
private bool _reuseAddress;
|
||||||
private ServerSslConfiguration _sslConfig;
|
private ServerSslConfiguration _sslConfig;
|
||||||
private List<ListenerAsyncResult> _waitQueue;
|
private List<HttpListenerAsyncResult> _waitQueue;
|
||||||
private object _waitQueueSync;
|
private object _waitQueueSync;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -103,7 +103,7 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
_prefixes = new HttpListenerPrefixCollection (this);
|
_prefixes = new HttpListenerPrefixCollection (this);
|
||||||
|
|
||||||
_waitQueue = new List<ListenerAsyncResult> ();
|
_waitQueue = new List<HttpListenerAsyncResult> ();
|
||||||
_waitQueueSync = ((ICollection) _waitQueue).SyncRoot;
|
_waitQueueSync = ((ICollection) _waitQueue).SyncRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ namespace WebSocketSharp.Net
|
|||||||
_connections[connection] = connection;
|
_connections[connection] = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ListenerAsyncResult BeginGetContext (ListenerAsyncResult asyncResult)
|
internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult)
|
||||||
{
|
{
|
||||||
CheckDisposed ();
|
CheckDisposed ();
|
||||||
if (_prefixes.Count == 0)
|
if (_prefixes.Count == 0)
|
||||||
@ -521,7 +521,7 @@ namespace WebSocketSharp.Net
|
|||||||
lock (_ctxRegistrySync)
|
lock (_ctxRegistrySync)
|
||||||
_ctxRegistry[context] = context;
|
_ctxRegistry[context] = context;
|
||||||
|
|
||||||
ListenerAsyncResult ares = null;
|
HttpListenerAsyncResult ares = null;
|
||||||
lock (_waitQueueSync) {
|
lock (_waitQueueSync) {
|
||||||
if (_waitQueue.Count == 0) {
|
if (_waitQueue.Count == 0) {
|
||||||
lock (_ctxQueueSync)
|
lock (_ctxQueueSync)
|
||||||
@ -612,7 +612,7 @@ namespace WebSocketSharp.Net
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public IAsyncResult BeginGetContext (AsyncCallback callback, Object state)
|
public IAsyncResult BeginGetContext (AsyncCallback callback, Object state)
|
||||||
{
|
{
|
||||||
return BeginGetContext (new ListenerAsyncResult (callback, state));
|
return BeginGetContext (new HttpListenerAsyncResult (callback, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -658,7 +658,7 @@ namespace WebSocketSharp.Net
|
|||||||
if (asyncResult == null)
|
if (asyncResult == null)
|
||||||
throw new ArgumentNullException ("asyncResult");
|
throw new ArgumentNullException ("asyncResult");
|
||||||
|
|
||||||
var ares = asyncResult as ListenerAsyncResult;
|
var ares = asyncResult as HttpListenerAsyncResult;
|
||||||
if (ares == null)
|
if (ares == null)
|
||||||
throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult");
|
throw new ArgumentException ("A wrong IAsyncResult.", "asyncResult");
|
||||||
|
|
||||||
@ -697,7 +697,7 @@ namespace WebSocketSharp.Net
|
|||||||
/// </exception>
|
/// </exception>
|
||||||
public HttpListenerContext GetContext ()
|
public HttpListenerContext GetContext ()
|
||||||
{
|
{
|
||||||
var ares = BeginGetContext (new ListenerAsyncResult (null, null));
|
var ares = BeginGetContext (new HttpListenerAsyncResult (null, null));
|
||||||
ares.InGet = true;
|
ares.InGet = true;
|
||||||
|
|
||||||
return EndGetContext (ares);
|
return EndGetContext (ares);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#region License
|
#region License
|
||||||
/*
|
/*
|
||||||
* ListenerAsyncResult.cs
|
* HttpListenerAsyncResult.cs
|
||||||
*
|
*
|
||||||
* This code is derived from System.Net.ListenerAsyncResult.cs of Mono
|
* This code is derived from System.Net.ListenerAsyncResult.cs of Mono
|
||||||
* (http://www.mono-project.com).
|
* (http://www.mono-project.com).
|
||||||
@ -42,7 +42,7 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace WebSocketSharp.Net
|
namespace WebSocketSharp.Net
|
||||||
{
|
{
|
||||||
internal class ListenerAsyncResult : IAsyncResult
|
internal class HttpListenerAsyncResult : IAsyncResult
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
#region Public Constructors
|
#region Public Constructors
|
||||||
|
|
||||||
public ListenerAsyncResult (AsyncCallback callback, object state)
|
public HttpListenerAsyncResult (AsyncCallback callback, object state)
|
||||||
{
|
{
|
||||||
_callback = callback;
|
_callback = callback;
|
||||||
_state = state;
|
_state = state;
|
||||||
@ -114,14 +114,9 @@ namespace WebSocketSharp.Net
|
|||||||
if (schm == AuthenticationSchemes.Anonymous)
|
if (schm == AuthenticationSchemes.Anonymous)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (schm == AuthenticationSchemes.None) {
|
|
||||||
context.Response.Close (HttpStatusCode.Forbidden);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var req = context.Request;
|
var req = context.Request;
|
||||||
var authRes = req.Headers["Authorization"];
|
|
||||||
if (schm == AuthenticationSchemes.Basic) {
|
if (schm == AuthenticationSchemes.Basic) {
|
||||||
|
var authRes = req.Headers["Authorization"];
|
||||||
if (authRes == null || !authRes.StartsWith ("basic", StringComparison.OrdinalIgnoreCase)) {
|
if (authRes == null || !authRes.StartsWith ("basic", StringComparison.OrdinalIgnoreCase)) {
|
||||||
context.Response.CloseWithAuthChallenge (
|
context.Response.CloseWithAuthChallenge (
|
||||||
AuthenticationChallenge.CreateBasicChallenge (listener.Realm).ToBasicString ());
|
AuthenticationChallenge.CreateBasicChallenge (listener.Realm).ToBasicString ());
|
||||||
@ -130,6 +125,7 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (schm == AuthenticationSchemes.Digest) {
|
else if (schm == AuthenticationSchemes.Digest) {
|
||||||
|
var authRes = req.Headers["Authorization"];
|
||||||
if (authRes == null || !authRes.StartsWith ("digest", StringComparison.OrdinalIgnoreCase)) {
|
if (authRes == null || !authRes.StartsWith ("digest", StringComparison.OrdinalIgnoreCase)) {
|
||||||
context.Response.CloseWithAuthChallenge (
|
context.Response.CloseWithAuthChallenge (
|
||||||
AuthenticationChallenge.CreateDigestChallenge (listener.Realm).ToDigestString ());
|
AuthenticationChallenge.CreateDigestChallenge (listener.Realm).ToDigestString ());
|
||||||
@ -158,7 +154,7 @@ namespace WebSocketSharp.Net
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void complete (ListenerAsyncResult asyncResult)
|
private static void complete (HttpListenerAsyncResult asyncResult)
|
||||||
{
|
{
|
||||||
asyncResult._completed = true;
|
asyncResult._completed = true;
|
||||||
|
|
@ -85,7 +85,6 @@
|
|||||||
<Compile Include="Net\HttpListenerResponse.cs" />
|
<Compile Include="Net\HttpListenerResponse.cs" />
|
||||||
<Compile Include="Net\HttpStreamAsyncResult.cs" />
|
<Compile Include="Net\HttpStreamAsyncResult.cs" />
|
||||||
<Compile Include="Net\HttpUtility.cs" />
|
<Compile Include="Net\HttpUtility.cs" />
|
||||||
<Compile Include="Net\ListenerAsyncResult.cs" />
|
|
||||||
<Compile Include="Net\RequestStream.cs" />
|
<Compile Include="Net\RequestStream.cs" />
|
||||||
<Compile Include="Net\ResponseStream.cs" />
|
<Compile Include="Net\ResponseStream.cs" />
|
||||||
<Compile Include="Net\WebHeaderCollection.cs" />
|
<Compile Include="Net\WebHeaderCollection.cs" />
|
||||||
@ -137,6 +136,7 @@
|
|||||||
<Compile Include="Net\ClientSslConfiguration.cs" />
|
<Compile Include="Net\ClientSslConfiguration.cs" />
|
||||||
<Compile Include="Net\ServerSslConfiguration.cs" />
|
<Compile Include="Net\ServerSslConfiguration.cs" />
|
||||||
<Compile Include="Net\SslConfiguration.cs" />
|
<Compile Include="Net\SslConfiguration.cs" />
|
||||||
|
<Compile Include="Net\HttpListenerAsyncResult.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user