[Mono-bugs] [Bug 688100] New: HttpWebRequest.set_Host() raises IndexOutOfRangeException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Apr 18 05:53:14 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=688100

https://bugzilla.novell.com/show_bug.cgi?id=688100#c0


           Summary: HttpWebRequest.set_Host() raises
                    IndexOutOfRangeException
    Classification: Mono
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: Other
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: gonzalo at novell.com
        ReportedBy: aenomoto at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


The following repro uses HttpWebRequest.Host setter which causes the exception
pasted later:

-----
using System;
using System.IO;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;

public class Test
{
    public static void Main ()
    {
        var hr = (HttpWebRequest) WebRequest.Create (new Uri
("http://localhost:8080"));
        hr.Method = "POST";
        hr.ContentType = "text/xml; charset=utf-8";
        hr.Host = "localhost:8080";
        hr.Headers ["SOAPAction"] = "\"urn:foo\"";
        var rs = new StreamWriter (hr.GetRequestStream ());
        rs.WriteLine (@"<s:Envelope
xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Header>
<To s:mustUnderstand='1'
xmlns='http://schemas.microsoft.com/ws/2005/05/addressing/none'>http://localhost:8080/</To>
</s:Header>
<s:Body />
</s:Envelope>");
        rs.Close ();
        var rr = new StreamReader (hr.GetResponse ().GetResponseStream ());
        Console.WriteLine (rr.ReadToEnd ());
        rr.Close ();
    }
}

-----

(Run "nc -l -p 8080" on another terminal in case you want to see complete
request.)

$ mono --debug x.exe

Unhandled Exception: System.IndexOutOfRangeException: Array index is out of
rang
e.
  at System.Net.HttpWebRequest.CheckValidHost (System.String val) [0x00066] in
C:\cygwin\home\atsushi\svn\mono\mcs\class\System\System.Net\HttpWebRequest.cs:415

  at System.Net.HttpWebRequest.set_Host (System.String value) [0x00011] in
C:\cygwin\home\atsushi\svn\mono\mcs\class\System\System.Net\HttpWebRequest.cs:390
  at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:set_Host
(string)
  at Test.Main () [0x00000] in <filename unknown>:0

-----

(It's not precisely the latest master, but I assume it would still happen.)

Might be Windows-only issue.

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


More information about the mono-bugs mailing list