2009-05-16 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / System.Net / ListenerAsyncResult.cs
index f926f8d46f03ff20bf7b7c8f2d37b7ae55e50d2e..c63f047231d8e5343bf2a9226ae72310708b742d 100644 (file)
@@ -82,7 +82,13 @@ namespace System.Net {
                                if (handle != null)
                                        handle.Set ();
 
-                               if (cb != null)
+                               if ((context.Listener.AuthenticationSchemes == AuthenticationSchemes.Basic || context.Listener.AuthenticationSchemes == AuthenticationSchemes.Negotiate) && context.Request.Headers ["Authorization"] == null) {
+                                       context.Listener.EndGetContext (this);
+                                       context.Response.StatusCode = 401;
+                                       context.Response.Headers ["WWW-Authenticate"] = AuthenticationSchemes.Basic + " realm=\"\"";
+                                       context.Response.OutputStream.Close ();
+                                       context.Listener.BeginGetContext (cb, state);
+                               } else if (cb != null)
                                        ThreadPool.QueueUserWorkItem (InvokeCallback, this);
                        }
                }