You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2012/02/07 23:40:58 UTC

svn commit: r1241677 - in /avro/trunk: CHANGES.txt lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java

Author: cutting
Date: Tue Feb  7 22:40:58 2012
New Revision: 1241677

URL: http://svn.apache.org/viewvc?rev=1241677&view=rev
Log:
AVRO-1005. Java: Extend HttpTransceiver to permit specification of a Proxy.  Contributed by Craig Landry.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1241677&r1=1241676&r2=1241677&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Feb  7 22:40:58 2012
@@ -51,6 +51,9 @@ Avro 1.6.2 (unreleased)
     AVRO-1016. Java: Add Field#getAliases() method to better permit
     copying of schemas. (cutting)
 
+    AVRO-1005. Java: Extend HttpTransceiver to permit specification of
+    a Proxy. (Craig Landry via cutting)
+
   BUG FIXES
 
     AVRO-962. Java: Fix Maven plugin to support string type override.

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java?rev=1241677&r1=1241676&r2=1241677&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java Tue Feb  7 22:40:58 2012
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.EOFException;
+import java.net.Proxy;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
@@ -33,11 +34,17 @@ public class HttpTransceiver extends Tra
   static final String CONTENT_TYPE = "avro/binary"; 
 
   private URL url;
+  private Proxy proxy;
   private HttpURLConnection connection;
   private int timeout;
   
   public HttpTransceiver(URL url) { this.url = url; }
 
+  public HttpTransceiver(URL url, Proxy proxy) {
+    this(url);
+    this.proxy = proxy;
+  }
+
   /** Set the connect and read timeouts, in milliseconds. */
   public void setTimeout(int timeout) { this.timeout = timeout; }
 
@@ -49,7 +56,11 @@ public class HttpTransceiver extends Tra
 
   public synchronized void writeBuffers(List<ByteBuffer> buffers)
     throws IOException {
-    connection = (HttpURLConnection)url.openConnection();
+    if (proxy == null)
+      connection = (HttpURLConnection)url.openConnection();
+    else
+      connection = (HttpURLConnection)url.openConnection(proxy);
+
     connection.setRequestMethod("POST");
     connection.setRequestProperty("Content-Type", CONTENT_TYPE);
     connection.setRequestProperty("Content-Length",