Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » Reuse Eclipse proxy handling when making HTTP connections
Reuse Eclipse proxy handling when making HTTP connections [message #1403643] Thu, 24 July 2014 18:30 Go to next message
Marcel Bruch is currently offline Marcel BruchFriend
Messages: 289
Registered: July 2009
Senior Member

Hi,

I'm currently struggling with making HTTP connections using proxies in Eclipse and I need a some pointers (and I hope to get them here).

We have several locations in code that do http requests. All these locations need to respect the user's proxy settings as specified in Eclipse preferences (native proxy, manual proxy, direct etc.).

Currently, I have to take care of this at every location, e.g. as shown below:

@Override
public HttpURLConnection getHttpURLConnection(URL url) throws IOException {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
return (HttpURLConnection) url.openConnection(proxy);
}
});

I wonder whether there is something (besides IProxyService/ProxyData) that I could reuse to get the proxy handling right. For instance, in the example above: is there a way how this could be simplified using ECF?

Thanks for some pointers
Marcel
Re: Reuse Eclipse proxy handling when making HTTP connections [message #1403647 is a reply to message #1403643] Thu, 24 July 2014 19:20 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
First, you might want to be aware of this apparent proxy bug that was discovered in Apache httpcomponents 4.2:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=422665

It seems to be limited to NTLMv2 proxies...with authentication...so it may not be relevant to you, but it may be. We are trying to figure out what to do about it for Luna SR 1, as it seems to be caused by the change from using httpcomponents 4.1 in Kepler (no problem) to 4.2 in Luna.

Second, ECF filetransfer *optionally* uses the Eclipse proxy API config (if org.eclipse.core.runtime.net is present in framework). If it is present, then ECF filetransfer provider uses the proxy information across any/all filetransfer providers (httpcomponents 4, jre urlconnection). If the Eclipse proxy API is not present, then ECF falls back on using the JRE proxy config (i.e. the proxy.* Java system properties).

So if you didn't want to use IProxyService, you could simply leave out the org.eclipse.core.runtime.net bundle from your environment, and use the JRE system properties. Also, you can use either the httpcomponents 4, httpclient 3.1, or the jre/urlconnection-based provider, just by including or leaving out the appropriate bundles. For example, it may be that in your proxy environment the best thing would be the jre/urlconnection-based provider. ECF will fall back to using that provider if the httpcomponents 4 provider bundles are not present in a given framework (at runtime).

There's much more detail, obviously, but hopefully this can get a discussion started.
Re: Reuse Eclipse proxy handling when making HTTP connections [message #1403652 is a reply to message #1403647] Thu, 24 July 2014 20:41 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
One more thing to mention...you are also completely free to create a new filetransfer provider of your own, and if you desire you may extend one of the existing ECF ones (and override the appropriate methods). This is intended to make it very easy to create a customer provider.

Re: Reuse Eclipse proxy handling when making HTTP connections [message #1404296 is a reply to message #1403652] Thu, 31 July 2014 05:04 Go to previous message
Marcel Bruch is currently offline Marcel BruchFriend
Messages: 289
Registered: July 2009
Senior Member

Sorry, I was off for a few days. I get an idea how ECF works here. One more question: Can you tell me where (full qualified classnames) ECF is doing the proxy handling for manual and native proxy settings?
Previous Topic:Problem getting Hello DS example to work
Next Topic:Http Browsing
Goto Forum:
  


Current Time: Thu Apr 25 01:16:54 GMT 2024

Powered by FUDForum. Page generated in 0.03509 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top