You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2011/12/01 15:46:41 UTC
Getting around HttpUrlConnection restrictions
There is a system property that disables it -- read once -- in a static block.
Does anyone thing it would be possible to create an independent class
loader and load this class into it a second time, with the property
set, and then talk to it via reflection?
Re: Getting around HttpUrlConnection restrictions
Posted by Benson Margulies <bi...@gmail.com>.
On Thu, Dec 1, 2011 at 10:34 AM, Daniel Kulp <dk...@apache.org> wrote:
> On Thursday, December 01, 2011 9:46:41 AM Benson Margulies wrote:
>> There is a system property that disables it -- read once -- in a static
>> block.
>>
>> Does anyone thing it would be possible to create an independent class
>> loader and load this class into it a second time, with the property
>> set, and then talk to it via reflection?
>
> Wouldn't it be easier to just use a little reflection to grab the set and call
> remove on it:
That hasn't occurred to me.
>
> Class cls = Class.forName("sun.net.www.protocol.http.HttpURLConnection");
> Field f = cls.getDeclaredField("restrictedHeaderSet");
> f.setAssible(true);
> ((Set)f.get(null)).remove("origin");
>
>
> Now, that will likely not work in OSGi as the Class.forName is likely to
> completely fail. Would need to figure something else out there. Probably
> would have to allow the system to export that package.
>
>
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
Re: Getting around HttpUrlConnection restrictions
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday, December 01, 2011 9:46:41 AM Benson Margulies wrote:
> There is a system property that disables it -- read once -- in a static
> block.
>
> Does anyone thing it would be possible to create an independent class
> loader and load this class into it a second time, with the property
> set, and then talk to it via reflection?
Wouldn't it be easier to just use a little reflection to grab the set and call
remove on it:
Class cls = Class.forName("sun.net.www.protocol.http.HttpURLConnection");
Field f = cls.getDeclaredField("restrictedHeaderSet");
f.setAssible(true);
((Set)f.get(null)).remove("origin");
Now, that will likely not work in OSGi as the Class.forName is likely to
completely fail. Would need to figure something else out there. Probably
would have to allow the system to export that package.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com