[Mono-list] bug in HttpWebRequest and https ?

Harobed mailing@harobed.org
Tue, 13 Jul 2004 01:26:25 +0200


Hello, 

This code get web page from "https://" URL.
When I start this code, I've this error :

Unhandled Exception: System.Net.WebException: Error getting response
stream: ReceiveFailure ---> System.ObjectDisposedException: The object
was used after being disposed.
in <0x00036> Mono.Security.Protocol.Tls.SslClientStream:checkDisposed ()
in <0x0004f> (wrapper remoting-invoke-with-check)
Mono.Security.Protocol.Tls.SslClientStream:checkDisposed ()
in <0x0004d> Mono.Security.Protocol.Tls.SslClientStream:BeginRead
(byte[],int,int,System.AsyncCallback,object)
in <0x0007e> System.Net.WebConnection:InitRead (object)
--- End of inner exception stack trace ---
 
in <0x0006e> System.Net.HttpWebRequest:CheckFinalStatus
(System.Net.WebAsyncResult)
in <0x00065> (wrapper remoting-invoke-with-check)
System.Net.HttpWebRequest:CheckFinalStatus (System.Net.WebAsyncResult)
in <0x001b7> System.Net.HttpWebRequest:EndGetResponse
(System.IAsyncResult)
in <0x0006d> System.Net.HttpWebRequest:GetResponse ()
in <0x000d9> Prog:Main (string[])

It's one bug, or my code is bad ?

This code success with "http://" URL.

Thanks.


----

using System;
using System.Net;
using System.Text;
using System.IO;

class Prog 
{

	static void Main(string[] args) 
	{
		HttpWebRequest WRequest = (HttpWebRequest) WebRequest.Create("https://localhost");
		
		HttpWebResponse WResponse = (HttpWebResponse) WRequest.GetResponse();
		
		StreamReader SR = new StreamReader(WResponse.GetResponseStream(), Encoding.ASCII);
			
		try 
		{
			string s = SR.ReadLine();
			while (s!=null)
			{
				Console.WriteLine(s);
				s = SR.ReadLine();
			}
		}
		finally
		{
			SR.Close();
		}
	}
}  

-- 
Stéphane KLEIN
Home page : http://www.harobed.org
Jabber : harobed@myjabber.net