2009-05-16 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / System.Net / ListenerAsyncResult.cs
index 7d21718f0b8181a0fdfee2cf79c4d2ed684b6c4d..c63f047231d8e5343bf2a9226ae72310708b742d 100644 (file)
@@ -27,7 +27,9 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
+
+#if NET_2_0 && SECURITY_DEP
+
 using System.Threading;
 namespace System.Net {
        class ListenerAsyncResult : IAsyncResult {
@@ -80,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);
                        }
                }