[Mono-bugs] [Bug 560679] New: HttpListener with Basic authentication raises an error when a non-Basic request arrived

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Dec 4 01:47:18 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=560679

http://bugzilla.novell.com/show_bug.cgi?id=560679#c0


           Summary: HttpListener with Basic authentication raises an error
                    when a non-Basic request arrived
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i586
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: aenomoto at novell.com
         QAContact: mono-bugs at lists.ximian.com
                CC: gonzalo at novell.com
          Found By: ---
           Blocker: ---


The following example demonstrates HttpListener usage with Basic
authentication. When it received a request without basic authentication header,
it shows behavioral difference between .NET and Mono.
- .NET HttpListener just silently ignores such a request and stays around as if
there were no request.
- Mono HttpListener retrieves the context (by GetContext()) and tries to
respond to the client, while the stream has already been disposed (as it has
already sent 401).

repro:

using System;
using System.IO;
using System.Net;

public class Test
{
        public static void Main ()
        {
                var h = new HttpListener ();
                h.AuthenticationSchemes = AuthenticationSchemes.Basic;
                h.Prefixes.Add ("http://localhost:8080/");
                h.Start ();
                var c = h.GetContext ();
                Console.WriteLine ("Retrieved a context");
                using (var sw = new StreamWriter (c.Response.OutputStream))
                        sw.Write ("OK");
                h.Close ();
        }
}

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list