[Mono-bugs] [Bug 80709][Nor] New - HttpWebRequest authentication does not work as it does in .Net

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Feb 2 18:49:32 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by abovill at fnfr.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80709

--- shadow/80709	2007-02-02 18:49:31.000000000 -0500
+++ shadow/80709.tmp.10639	2007-02-02 18:49:31.000000000 -0500
@@ -0,0 +1,243 @@
+Bug#: 80709
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: Windows XP SP2 & Fedora FC3 2.6.12-1.1381_FC3
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: abovill at fnfr.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: HttpWebRequest authentication does not work as it does in .Net
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+When doing an HttpWebRequest to a server with authentication, the request
+fails under mono.  It gets the 401 Unauthorized response and then does not
+resend with authentication.
+
+
+Steps to reproduce the problem:
+1. Code:
+You will have to fill in a url to a server that supports authentication and
+the appropriate userID and Password.
+
+----------------------------------------------------
+using System;
+using System.Net;
+using System.Text;
+using System.IO;
+
+namespace HttpAuthProblem
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            try {
+                string url = "http://<server that supports authentication>";
+                string userid = "<user name>";
+                string password = "<password>";
+                HttpWebRequest hwReq = (HttpWebRequest)WebRequest.Create(url);
+
+                hwReq.Credentials = new NetworkCredential(userid, password);
+                HttpWebResponse response =
+(HttpWebResponse)hwReq.GetResponse();
+                Console.WriteLine("response:" + response.ResponseUri);
+                // get the response stream.
+                Stream responseStream = response.GetResponseStream();
+                // use a stream reader that understands UTF8
+                StreamReader reader = new StreamReader(responseStream,
+Encoding.UTF8);
+                string html = "";
+                try {
+                    html = reader.ReadToEnd();
+                }
+                finally {
+                    // close the reader
+                    reader.Close();
+                }
+
+                Console.WriteLine("response:" + html);
+            }
+            catch (Exception ex) {
+                Console.WriteLine("Exception:" + ex.ToString());
+
+            }
+        }
+    }
+}
+
+-------------------------------------------------------
+2. compile
+3. run
+
+Actual Results:
+Execute in Mono 1.2.3
+------------------------------
+Exception:System.Net.WebException: The remote server returned an error:
+(401) Unauthorized.
+  at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult
+result) [0x00000]
+  at System.Net.HttpWebRequest.SetResponseData
+(System.Net.WebConnectionData data) [0x00000]
+
+Expected Results:
+
+Executed in .Net 2.0
+-----------------------------------------
+response:http://dutcisco3750/xhome.htm
+response:<!-- // Copyright (c) 2003, 2004 by Cisco Systems, Inc. -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title> Cisco Catalyst Switch - Home</title>
+<script language="JavaScript" src="appsui.js">
+  </script>
+<script language="JavaScript" src="common.js">
+  </script>
+<script language="JavaScript" src="sitewide.js">
+  </script>
+<script language="JavaScript" src="forms.js">
+  </script>
+<script language="JavaScript">
+<!--
+
+var IP_Address = "";
+var cms_ip = "";
+var ipInterfaces = null;
+var activeInterface = null;
+
+DLIM_WhSp = /[\s]+/;
+DLIM_WhSp_slash = /[\/\s]+/;
+DLIM_WhSp_comma = /[\,\s]+/;
+DLIM_WhSp_parens = /[\(\)\s]+/;
+DLIM_WhSp_colon = /[\:\s]+/;
+DLIM_newline = /[\r\n]+/;
+.
+.
+. {WEB PAGE BODY}
+</html>
+-------------------------------------------
+
+
+Executed in mono 1.1.18
+-------------------------------------------
+C:\svt\MonoBugs\HttpAuthProblem>mono --version
+Mono JIT compiler version 1.1.18, (C) 2002-2006 Novell, Inc and
+Contributors. www.mono-project.com
+        TLS:           normal
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV:       normal
+        Disabled:      none
+
+C:\svt\MonoBugs\HttpAuthProblem>mono Program.exe
+response:http://dutcisco3750/xhome.htm
+response:<!-- // Copyright (c) 2003, 2004 by Cisco Systems, Inc. -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title> Cisco Catalyst Switch - Home</title>
+<script language="JavaScript" src="appsui.js">
+  </script>
+<script language="JavaScript" src="common.js">
+  </script>
+<script language="JavaScript" src="sitewide.js">
+  </script>
+<script language="JavaScript" src="forms.js">
+  </script>
+<script language="JavaScript">
+<!--
+
+var IP_Address = "";
+var cms_ip = "";
+var ipInterfaces = null;
+var activeInterface = null;
+
+--------------------------------------------
+
+How often does this happen? 
+
+All the time.
+
+
+Additional Information:
+
+Ethereal Capture from MONO:
+---------------------------
+GET /xhome.htm HTTP/1.1
+Connection: keep-alive
+Host: dutcisco3750
+
+
+
+HTTP/1.0 401 Unauthorized
+Date: Wed, 10 Mar 1993 01:18:17 UTC
+Content-type: text/html
+Expires: Thu, 16 Feb 1989 00:00:00 GMT
+WWW-Authenticate: Basic realm="level 15 access"
+<HEAD><TITLE>Authorization Required</TITLE></HEAD><BODY><H1>Authorization
+Required</H1>Browser not authentication-capable or authentication
+failed.</BODY>
+
+
+---------------------------
+Ethereal Capture from .Net:
+---------------------------
+GET /xhome.htm HTTP/1.1
+Host: dutcisco3750
+Connection: Keep-Alive
+
+
+HTTP/1.0 401 Unauthorized
+Date: Wed, 10 Mar 1993 01:18:01 UTC
+Content-type: text/html
+Expires: Thu, 16 Feb 1989 00:00:00 GMT
+WWW-Authenticate: Basic realm="level 15 access"
+<HEAD><TITLE>Authorization Required</TITLE></HEAD><BODY><H1>Authorization
+Required</H1>Browser not authentication-capable or authentication
+failed.</BODY>
+
+
+
+GET /xhome.htm HTTP/1.1
+Authorization: Basic ZmFuZmFyZTpmYW5mYXJl
+Host: dutcisco3750
+Connection: Keep-Alive
+
+
+
+HTTP/1.0 200 OK
+Date: Wed, 10 Mar 1993 01:18:01 UTC
+Server: cisco-IOS/12.2 HTTP-server/1.0(1)
+Mime-version: 1.0
+Pragma: no-cache
+content-type: text/html
+<!-- // Copyright (c) 2003, 2004 by Cisco Systems, Inc. -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title> Cisco Catalyst Switch - Home</title>
+<script language="JavaScript" src="appsui.js">
+  </script>
+<script language="JavaScript" src="common.js">
+  </script>
+<script language="JavaScript" src="sitewide.js">
+  </script>
+<script language="JavaScript" src="forms.js">
+  </script>
+<script language="JavaScript">
+<!--
+.
+.
+.
+.
+.<content continues>


More information about the mono-bugs mailing list