[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
+
+‹
+ÿWmoÛ6þž_Á*€_[²�8I£—aÙÖ&C:h‹a@€‚’(‰ˆD*$e×úßw)Ûy]jÔb‘¾;>÷Üïª*£
+ 8�‚Š(Œ
+¥ê1¹mè"tÎaj¬V5q�]…Ž"ß”§}”XH¢Â/Ÿß�O�(PT•$zÏy^’À3«@ª•þz3ïÅ<]�T:£zäw˜g¸¢åêŠË‘ÄLŽ%4ó¿ïu’þKÎÐlRÓ›·w
+/¹8ÛŸÀ'I|gœ’„¬(ggˆqF@ÐóÆãh/ðÌñ{�L<h
+YÃ-�d6Þ¥<i*ðÍÍÜ[7ƒ…ÁÂZ(Ô£rD†w,PnÄ}š¡Aæb#Öë¡õO9Q”D?ž¯.Ó!jU‹-Ýû§Èœak®È¬´B!rÊêF!‚°
+iJb¸"¡Â1Zà²!¡sP8‘ã™K#ââó‡«Pùß×°BÔ×Q=ó¼þAí7Á,!åyÇ%Øñ3W6qEx-ˆjC.%�hW�fYJ;*=“9:¬(ÎÛ¸„ûYûA:.a¤É•”Ý„6bhaVóùŸÆ›U–µ‚œ]qœ†:,Q�
+;D@Za€Šb.R" ô¥¬qBYnW5NÓv²Z0Ñ*GR$¡ãÑ
+çDz%Ϲ›ÓÌAKšª"œ�£‚мPát:�Ú&s!‘=mÂÓ¶¼öpðQ€¿?Ä6�G=ËÚ7–aŸ¦
+²æìððø˜.r·æÛ9$ôRà:
+t1 û$ëÒÇS€ýMâÀ‹°‹Öç¼pþts>Éôß‹çCh~+ir:6+’A¹\ºyË™›ð
+˜Î‹º?ê/iD`eè;¨¿0i„„¢9Õ¶}»,0Ký(À-Œ’KÞ¢B�¬˜û¥(CÂzÀ|¸¤=JÌ]ÓãöÁÙ–e³ãï²Í‘5wøUüÍ~6¹¨Ð|þf�økÍmó—ïÆßS°ð÷^ð¦þQþ6)hº‡�økÍmó—îÆßS°ð÷;$Q\¬~�£ŸM![Jƒ•í@áÑ#
+[sÛ²Ý(|
+Ö
+ÿ"Ë×'`{µÛøƒKœ…ÓÙÃûØtk`Ý,L«x®I (Q!Óz� I°H
+Ç4í¬ke¯o'�¢¾àè¹ñ
+(ít@`à�Oç{zñ¬%ÝPÑMtÏòg+ü튰\·×ù± Í|nTn;Çð´eÙLÝï¦ £OÛÌÅŠ½Aå²_¡w„À$‘£«&¹YmÔ.7™°0Ô)^ßo©&ƒf–èÞþélvì[Ö±Éd§=6¥_M@MJG¿Ú]#l·É¾d†ÿDP•ÖÒÇÍÎk”˜å´¬¯ŠCöZWv}Ö›¦¶†�{™êé45�0I»UIÝ)x-=G{I„¢’Kª
+óô¥=�ÑFf÷'@í¼‘”)-9¼ltM<Váu»Ÿ¬²õWµõ{íЖ¢‡cÞ(·}ƒù“ÇrdD�HÙ=oY¸ eÝ2².†Ú^kNL
+¼ p•5¢ì§$ÃM©ö^‘È:]Ñl^!<¯}‰ÐÓú›¢v©¼ á� <è&í×W3ýzô_
+ªÈÀ ê5Ó׎Wå+0¥½¹Þ\ˆ×N‹Ñí
+†ý§1ö}xûþµ}À7Ùû‡7]X#o4=ÎpûÍɸÛ%Ñ£rIx½òg“ÉQgol‹V—ááèpr2zûött2™¢%‰Q}oÄk^w‰yú¾ÚXþJã†k”
+
+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>