dan6886 / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

New Feature: JDK 1.5 Proxy. #78

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Since Java JDK 1.5, a java.net.Proxy class is available to configure http
requests to use a particular proxy server and port. This can override Java
System Properties http.proxyHost etc. 

The advantage is users of GData services can opt to be specific about proxy
servers and proxy authentication. 

This is a feature request for the GData API.

*User API interface example;
YouTubeService gdata = new YouTubeService("nswdet-test-x01");
SocketAddress addr = new InetSocketAddress("proxy.det.nsw.edu.au", 8080);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
Authenticator.setDefault(new BasicAuthenticator("username", "password"));
gdata.setProxy(proxy);

*What version of the product are you using? On what operating system?
GData: 1.24.0, Java SDK 1.6, Linux 2.6, Sun JEE 5 update 5.

*Please provide any additional information below.

A quick look in the GData code, I can see the following changes;
in file: 
com.google.gdata.client.http.HttpGDataRequest
add - 
static protected Proxy   proxyServer = null;

and add getter/setter methods for getProxy() and setProxy() in the Factory
static inner class;
    public void setProxy(Proxy server) {
        proxyServer = server;
    }

    public Proxy getProxy() {
        return proxyServer;
    }

in the method -
protected HttpURLConnection getRequestConnection(URL requestUrl) throws
IOException

add code to actually set the proxy on the URL openConnection

if (proxyServer != null) {
   uc = (HttpURLConnection) requestUrl.openConnection(proxyServer);
}

then in file -
com.google.gdata.client.Service
add getter/setter methods;

  public void setProxy(Proxy server) {
      ((HttpGDataRequest.Factory)this.requestFactory).setProxy(server);
  }

  public Proxy getProxy() {
      return ((HttpGDataRequest.Factory)this.requestFactory).getProxy();
  }

 JavaDocs for the Proxy class at;
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.html
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Authenticator.html

Original issue reported on code.google.com by shamilt...@gmail.com on 10 Nov 2008 at 1:11

GoogleCodeExporter commented 9 years ago
Thanks for the detailed bug report.  I have filed this as internal bug 
#1696641.  In
the meantime, if you'd like this change sooner, please create a patch to the 
current
Java code and attach it to this bug report.  Thanks!

Original comment by mon...@gmail.com on 6 Mar 2009 at 8:13