[Mono-bugs] [Bug 312968] HttpWebRequest can not handle WWW-Authenticate with POST

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Aug 31 20:30:23 EDT 2009


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

User greg.smolyn at strangeloopnetworks.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=312968#c1


Greg Smolyn <greg.smolyn at strangeloopnetworks.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |REOPENED
                 CC|                            |greg.smolyn at strangeloopnetw
                   |                            |orks.com
         Resolution|FIXED                       |
           Severity|Enhancement                 |Normal




--- Comment #1 from Greg Smolyn <greg.smolyn at strangeloopnetworks.com>  2009-08-31 18:30:17 MDT ---
I am able to reproduce this in my code, using build 140267 from trunk.

We see _exactly_ this behaviour, but only when using SSL.  

When in non-SSL mode, we see an exception right away in 2 scenarios:

Scenario 1: We set the ContentLength, we get this

System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.WebConnection.EndWrite2 (System.Net.HttpWebRequest request,
IAsyncResult result) [0x00019] in
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnection.cs:889 
  at System.Net.WebConnectionStream.WriteRequestAsyncCB (IAsyncResult r)
[0x0000c] in
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnectionStServer

Scenario 2: We don't set the ContentLength, we get his:

System.ObjectDisposedException: The object was used after being disposed.
  at System.Net.WebConnection.EndWrite (System.Net.HttpWebRequest request,
IAsyncResult result) [0x00019] in
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnection.cs:908 
  at System.Net.WebConnectionStream.WriteRequest () [0x00193] in
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnectionStream.cs:696 
  at System.Net.WebConnectionStream.Close () [0x0012e] in
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnectionStream.cs:750


So for SSL mode, when we pause the debugger, it looks something like this:

(*) #0: 0x7f30e1d9856d in __pthread_cond_timedwait+0x13d
    #1: 0x4027450a in <(wrapper managed-to-native)
System.Threading.WaitHandle:WaitOne_internal (intptr,int,bool)>+0x5a at 6
    #2: 0x403db084 in System.Threading.WaitHandle.WaitOne(int, bool)+0x84 at
/home/smolyn/src/mono/mono-2.5.1/mcs/class/corlib/System.Threading/WaitHandle.cs:339
    #3: 0x41ef2d7e in
Mono.Security.Protocol.Tls.SslStreamBase.EndWrite(System.IAsyncResult)+0x9e at
/home/smolyn/src/mono/mono-2.5.1/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:892
    #4: 0x41ef2c84 in
System.Net.WebConnection.EndWrite(System.Net.HttpWebRequest,
System.IAsyncResult)+0xf4 at
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnection.cs:915
    #5: 0x403e7cbc in System.Net.WebConnectionStream.WriteRequest()+0x2bc at
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnectionStream.cs:696
    #6: 0x403e790c in System.Net.WebConnectionStream.Close()+0x20c at
/home/smolyn/src/mono/mono-2.5.1/mcs/class/System/System.Net/WebConnectionStream.cs:751


Mostly this seems to happen only after the _second_ time we make a WebRequest
call... The first one we make usually works.


The code we're using to do this is fairly simple:
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => {
return true; };            

string pageUrl = new Uri(Program.ManagementUrl +
Node.Attributes["query"].Value).ToString();
request = (HttpWebRequest)WebRequest.Create(pageUrl);
request.Method = "POST";                   
request.UserAgent = "Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)";
request.Pipelined = false;

var cCache = new CredentialCache();
cCache.Add(new Uri(Program.ManagementUrl), "Basic", new
NetworkCredential(Program.UserName, Program.Password));                         
request.Credentials = cCache;
request.KeepAlive = false;

byte[] data = Encoding.ASCII.GetBytes(Post);    

Stream requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);   //gets stuck waiting here if we
set ContentLength
requestStream.Flush();
requestStream.Close();  // gets stuck waiting here if we don't set
ContentLength

-- 
Configure bugmail: http://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