[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] extending HttpsURLConnection

Hello all,

I'd like to create a new class which extends HttpsURLConnection (I want to
override the "setRequestMethod" to accept even non-standard methods).

So I implemented the class to be something like: 
public class MyHttpsURLConnection extends HttpsURLConnection

	public MyHttpsURLConnection(URL u) throws IOException
	public void setRequestMethod(String method) throws ProtocolException
		this.method = method;

But, as I understand, this is not enough, since when calling
"url.openConnection()", I need to get "MyHttpsURLConnection", and not other
so I created a subclass of iaik.protocol.https.Handler which looks something
public class MyHandler extends Handler
	protected URLConnection openConnection(URL u)
                                throws IOException
	    return new MyHttpsURLConnection(u);

and I give it as "addHandler" to HttpsURLStreamHandlerFactory instance.
So my main code looks like:
MyHandler my_handler = new MyHandler ();
		HttpsURLStreamHandlerFactory factory =  new
		factory.addHandler ("HTTPS", my_handler);
  	MyHttpsURLConnection con =
The problem is that I get a casting exception for the last line. Which means
that openConnection() didn't return the expected MyHttpsURLConnection
object but something else.

Does anyone has an idea what am I doing wrong?

Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-ssl