[Mono-bugs] [Bug 53941][Maj] New - HttpWebRequest proxy handling bug
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 5 Feb 2004 13:03:42 -0500 (EST)
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 liyul@hotmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=53941
--- shadow/53941 2004-02-05 13:03:42.000000000 -0500
+++ shadow/53941.tmp.27662 2004-02-05 13:03:42.000000000 -0500
@@ -0,0 +1,403 @@
+Bug#: 53941
+Product: Mono/Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: liyul@hotmail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: HttpWebRequest proxy handling bug
+
+It should actually be under System.Net which is not under the choice.
+
+HttpWebRequest proxy handling has problem with a home-grown proxy server
+which worked for both Java and IE. It doesn't handle proxy authentication
+automatically with either Microsoft or Netscape Proxy Server. And I haven't
+test to confirm whether it will work with Windows Integrated authentication.
+
+// ProxyTest.cs
+using System;
+using System.Net;
+using System.IO;
+
+namespace ProxyTest
+{
+ class ProxyTest
+ {
+ public static void Main()
+ {
+ string sRes=GetHtmlPage("http://www.google.com");
+ // Console.Write(sRes);
+ }
+
+ public static String GetHtmlPage(string strURL)
+ {
+ // the html retrieved from the page
+ string strResult=null;
+#if DEBUG
+#else
+ try
+ {
+#endif
+ HttpWebResponse objResponse;
+ HttpWebRequest objRequest = (HttpWebRequest)
+System.Net.HttpWebRequest.Create(strURL);
+
+ WebProxy myProxy;
+ myProxy=WebProxy.GetDefaultProxy();
+ // The following is needed for mono as GetDefaultProxy silently fails.
+ myProxy.Address=new Uri("http://MyProxyServer:8080");
+ myProxy.Credentials=new NetworkCredential("ProxyUser", "ProxyUser");
+ objRequest.Proxy=myProxy;
+
+ objRequest.Accept="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-powerpoint, application/vnd.ms-excel,
+application/msword, */*";
+ objRequest.Headers.Add("Accept-Language: en-us");
+ objRequest.Headers.Add("Accept-Encoding: gzip, deflate");
+ objRequest.UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
+5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)";
+ if (null!=myProxy.Address)
+ objRequest.Headers.Add("Pragma-Proxy: " + myProxy.Address.AbsoluteUri);
+
+ Console.WriteLine(objRequest.Method + " " + objRequest.RequestUri + "
+HTTP/" + objRequest.ProtocolVersion);
+ Console.WriteLine(objRequest.Headers.ToString());
+
+ objResponse = (HttpWebResponse) objRequest.GetResponse();
+ using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
+ {
+ // The result can be gzip/deflate format
+ // and Microsoft .net 1.1 wouldn't decompress automatically.
+ strResult = sr.ReadToEnd();
+ sr.Close();
+ }
+ Console.WriteLine(objRequest.Method + " " + objRequest.RequestUri + "
+HTTP/" + objRequest.ProtocolVersion);
+ Console.WriteLine(objRequest.Headers.ToString());
+
+ Console.WriteLine(((int) objResponse.StatusCode).ToString() + " " +
+objResponse.StatusDescription + " HTTP/" + objResponse.ProtocolVersion);
+ Console.WriteLine(objResponse.Headers.ToString());
+#if DEBUG
+#else
+ }
+ catch (Exception e)
+ {
+ strResult=e.ToString();
+ }
+#endif
+ return strResult;
+ }
+ }
+}
+
+Case I: Fail when authentication is not needed with home-grown proxy server
+# Client-->Proxy
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-powerpoint, application/vnd.ms-excel,
+application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+Host: www.google.com
+
+
+# Proxy-->Client
+HTTP/1.1 200 OK
+Cache-control: private
+Content-Type: text/html
+Set-Cookie:
+PREF=ID=32a561e6c4e83906:TM=1076001431:LM=1076001431:S=22lPUuhLanJUCMi0;
+expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
+Content-Encoding: gzip
+Server: GWS/2.1
+Date: Thu, 05 Feb 2004 17:17:11 GMT
+Proxy-Connection: Keep-Alive
+Content-Length: 1349
+
+
+Wmo6_*_[8Ia&C:ha@(D*$ew)y]jb;>*
+ 8(
+1m"tajV5q]"ߔ}XH/ߍO(PT$zy^3@z3<]T:£zwgˑL%4uKlRӛw
+/8۟'I|g(ggqF@h/{L<h
+Y-d6ޥ<i*[7Z(ԣrDw,Pn}Ab#O9QD?.!jU-ȜakȬB!rF!
+iJb"1Z!sP8K#PװBQ=A7,!y%3W6qEx-jC.%hWfYJ;*=9:(۸YA:.a݄6bhaVU]q:,Q
+;D@Zab.R" qBYnW5NvZ0*GR$
+Dz%ϹAK"мPt:&s!=mӶpQ?6G=7a
+.r9$R:
+t1 $SMpts>ߋCh~+ir:6+A\y˙
+?/iD`e;0i9ն},0K(-KޢB(Cz|=J]e͑5wU~6|fkmS^Q6)hkmS;$Q\~£M![J@#
+[s(|
+
+"'`{Ktk`,LxI (Q!z IH
+4keo'
+(t@`O{z%PMtg+튰\ |nTn;eL OŊA_w$&Ym.70)^o&flv[ֱd=6_M@MJG]#ldDPk崬CZWv}֛{450IUI)x-=G{IK
+=Ff'@)-9ltM<VuW{Жc(}rdDH=oY e2.^kNL
+ p5$M^:]l^!<}v <&W3z_
+ 5W+0\N
+1}x}77]X#o4=pɸ%ѣrIxgQgolVpr2ztt2%Q}ok^wyXJk
+
+http://www.google.com/ spent 711(ms) in getting response
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>mono ProxyTest.exe
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+
+Unhandled Exception: System.Net.WebException: Error getting response stream
+--->
+ System.Exception:
+ at System.Net.WebConnection.HandleError()
+ at System.Net.WebConnection.ReadDone()
+ at System.MulticastDelegate.invoke_void_IAsyncResult()
+ at System.Net.Sockets.Socket+Worker.End()
+ at System.Net.Sockets.Socket+Worker.Receive()
+in <0x000d3> System.Net.WebConnection:HandleError
+(System.Net.WebExceptionStatus
+,System.Exception)
+--- End of inner exception stack trace ---
+
+in <0x00069> System.Net.HttpWebRequest:CheckFinalStatus
+(System.Net.WebAsyncResu
+lt)
+in <0x00194> System.Net.HttpWebRequest:EndGetResponse (System.IAsyncResult)
+in <0x0006a> System.Net.HttpWebRequest:GetResponse ()
+in <0x002ce> ProxyTest.ProxyTest:GetHtmlPage (string)
+in <0x00016> ProxyTest.ProxyTest:Main ()
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>
+
+Case II: Fail when basic authentication is needed with home-grown proxy server
+# Client-->Proxy
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-powerpoint, application/vnd.ms-excel,
+application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+Host: www.google.com
+
+
+# Proxy-->Client
+HTTP/1.1 407 Proxy Authentication Required
+Proxy-Authenticate: Basic realm="My Proxy Server"
+
+
+http://www.google.com/ spent 361(ms) in getting response
+
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>mono ProxyTest.exe
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+
+Unhandled Exception: System.Net.WebException: Error getting response stream
+--->
+ System.Exception:
+ at System.Net.WebConnection.HandleError()
+ at System.Net.WebConnection.ReadDone()
+ at System.MulticastDelegate.invoke_void_IAsyncResult()
+ at System.Net.Sockets.Socket+Worker.End()
+ at System.Net.Sockets.Socket+Worker.Receive()
+in <0x000d3> System.Net.WebConnection:HandleError
+(System.Net.WebExceptionStatus
+,System.Exception)
+--- End of inner exception stack trace ---
+
+in <0x00069> System.Net.HttpWebRequest:CheckFinalStatus
+(System.Net.WebAsyncResu
+lt)
+in <0x00194> System.Net.HttpWebRequest:EndGetResponse (System.IAsyncResult)
+in <0x0006a> System.Net.HttpWebRequest:GetResponse ()
+in <0x002ce> ProxyTest.ProxyTest:GetHtmlPage (string)
+in <0x00016> ProxyTest.ProxyTest:Main ()
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>
+
+Case III: When windows integrated authentication is needed with ISA 2000
+ Microsoft .net 1.1 succeeded, mono failed.
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>ProxyTest
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+Proxy-Authorization: Negotiate
+TlRMTVNTUAADAAAAGAAYAGoAAAAYABgAggAAAAAAAABAAAAAE
+gASAEAAAAAYABgAUgAAABAAEACaAAAANYKI4FAAcgBvAHgAeQBVAHMAZQByAEQARQBMAEwALQA3ADcAN
+gAxADIANAAxAPJBsats90XLAAAAAAAAAAAAAAAAAAAAAChHLb1mCV1RwypXFS/a6zjLnqKhSrWNye0E/
+Ro1M2XstbnSd09t7PU=
+Host: www.google.com
+
+
+200 OK HTTP/1.1
+Via: 1.0 MyProxyServer
+Content-length: 1349
+Date: Thu, 05 Feb 2004 17:31:28 GMT
+Content-Type: text/html
+Cache-control: private
+Set-Cookie:
+PREF=ID=1cc8c7010fdfaa1d:TM=1076002288:LM=1076002288:S=DK9Z4EZNOWdB-
+JtR; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
+Content-Encoding: gzip
+Server: GWS/2.1
+
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>mono ProxyTest.exe
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+
+Unhandled Exception: System.Net.WebException: The remote server returned an
+erro
+r: (407) Proxy Authentication Required ( The ISA Server requires
+authorization t
+o fulfill the request. Access to the Web Proxy service is denied. ).
+in <0x002e2> System.Net.HttpWebRequest:CheckFinalStatus
+(System.Net.WebAsyncResu
+lt)
+in <0x00194> System.Net.HttpWebRequest:EndGetResponse (System.IAsyncResult)
+in <0x0006a> System.Net.HttpWebRequest:GetResponse ()
+in <0x002ce> ProxyTest.ProxyTest:GetHtmlPage (string)
+in <0x00016> ProxyTest.ProxyTest:Main ()
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>
+
+
+case IV: basic authentication is needed with Netscape Proxy Server 3.6
+ Microsoft .net 1.1 succeeded, mono failed.
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>ProxyTest
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+Proxy-Authorization: Basic UHJveHlVc2VyOlByb3h5VXNlcg==
+Proxy-Connection: Keep-Alive
+Host: www.google.com
+
+
+200 OK HTTP/1.1
+Cache-control: private
+Content-type: text/html
+Set-cookie:
+PREF=ID=22171658ab1c6559:TM=1076002416:LM=1076002416:S=HD9enoXR3oRxH
+CY6; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
+Content-encoding: gzip
+Server: GWS/2.1
+Content-length: 1349
+Date: Thu, 05 Feb 2004 17:33:36 GMT
+
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>mono ProxyTest.exe
+GET http://www.google.com/ HTTP/1.1
+Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
+application/vnd.ms-
+powerpoint, application/vnd.ms-excel, application/msword, */*
+Accept-Language: en-us
+Accept-Encoding: gzip, deflate
+User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR
+1.0.3705
+; .NET CLR 1.1.4322)
+Pragma-Proxy: http://MyProxyServer:8080/
+
+
+
+Unhandled Exception: System.Net.WebException: The remote server returned an
+erro
+r: (407) Proxy authorization required.
+in <0x002e2> System.Net.HttpWebRequest:CheckFinalStatus
+(System.Net.WebAsyncResu
+lt)
+in <0x00194> System.Net.HttpWebRequest:EndGetResponse (System.IAsyncResult)
+in <0x0006a> System.Net.HttpWebRequest:GetResponse ()
+in <0x002ce> ProxyTest.ProxyTest:GetHtmlPage (string)
+in <0x00016> ProxyTest.ProxyTest:Main ()
+
+
+E:\work\mono-0.30\ProxyTest\bin\Debug>