diff --git a/websocket-sharp/Net/HttpListenerAsyncResult.cs b/websocket-sharp/Net/HttpListenerAsyncResult.cs
index 77707667..286082b4 100644
--- a/websocket-sharp/Net/HttpListenerAsyncResult.cs
+++ b/websocket-sharp/Net/HttpListenerAsyncResult.cs
@@ -115,8 +115,9 @@ namespace WebSocketSharp.Net
return true;
var req = context.Request;
+ var authRes = req.Headers["Authorization"];
+
if (schm == AuthenticationSchemes.Basic) {
- var authRes = req.Headers["Authorization"];
if (authRes == null || !authRes.StartsWith ("basic", StringComparison.OrdinalIgnoreCase)) {
context.Response.CloseWithAuthChallenge (
AuthenticationChallenge.CreateBasicChallenge (listener.Realm).ToBasicString ());
@@ -125,7 +126,6 @@ namespace WebSocketSharp.Net
}
}
else if (schm == AuthenticationSchemes.Digest) {
- var authRes = req.Headers["Authorization"];
if (authRes == null || !authRes.StartsWith ("digest", StringComparison.OrdinalIgnoreCase)) {
context.Response.CloseWithAuthChallenge (
AuthenticationChallenge.CreateDigestChallenge (listener.Realm).ToDigestString ());
@@ -139,7 +139,7 @@ namespace WebSocketSharp.Net
}
var realm = listener.Realm;
- context.SetUser (schm, realm, listener.UserCredentialsFinder);
+ context.SetUser (authRes, schm, realm, listener.UserCredentialsFinder);
if (req.IsAuthenticated)
return true;
diff --git a/websocket-sharp/Net/HttpListenerContext.cs b/websocket-sharp/Net/HttpListenerContext.cs
index 7b37a272..fad63d70 100644
--- a/websocket-sharp/Net/HttpListenerContext.cs
+++ b/websocket-sharp/Net/HttpListenerContext.cs
@@ -44,8 +44,8 @@ using WebSocketSharp.Net.WebSockets;
namespace WebSocketSharp.Net
{
///
- /// Provides a set of methods and properties used to access the HTTP request and response
- /// information used by the .
+ /// Provides the access to the HTTP request and response information
+ /// used by the .
///
///
/// The HttpListenerContext class cannot be inherited.
@@ -160,15 +160,16 @@ namespace WebSocketSharp.Net
#region Internal Methods
internal void SetUser (
+ string response,
AuthenticationSchemes scheme,
string realm,
Func credentialsFinder)
{
- var authRes = AuthenticationResponse.Parse (_request.Headers ["Authorization"]);
- if (authRes == null)
+ var res = AuthenticationResponse.Parse (response);
+ if (res == null)
return;
- var id = authRes.ToIdentity ();
+ var id = res.ToIdentity ();
if (id == null)
return;