You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/06/19 20:56:42 UTC
svn commit: r786630 -
/incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java
Author: tvolkert
Date: Fri Jun 19 18:56:41 2009
New Revision: 786630
URL: http://svn.apache.org/viewvc?rev=786630&view=rev
Log:
Added proxy property to Query, allowing callers access to per-query-basis proxy settings
Modified:
incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java
Modified: incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java?rev=786630&r1=786629&r2=786630&view=diff
==============================================================================
--- incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java (original)
+++ incubator/pivot/trunk/web/src/org/apache/pivot/web/Query.java Fri Jun 19 18:56:41 2009
@@ -21,6 +21,7 @@
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
@@ -136,6 +137,7 @@
private URL locationContext = null;
private HostnameVerifier hostnameVerifier = null;
+ private Proxy proxy = null;
private QueryDictionary parameters = new QueryDictionary();
private QueryDictionary requestHeaders = new QueryDictionary();
@@ -212,6 +214,28 @@
this.hostnameVerifier = hostnameVerifier;
}
+ /**
+ * Gets the proxy associated with this query.
+ *
+ * @return
+ * This query's proxy, or <tt>null</tt> if the query is using the default
+ * JVM proxy settings
+ */
+ public Proxy getProxy() {
+ return proxy;
+ }
+
+ /**
+ * Sets the proxy associated with this query.
+ *
+ * @param proxy
+ * This query's proxy, or <tt>null</tt> to use the default JVM proxy
+ * settings
+ */
+ public void setProxy(Proxy proxy) {
+ this.proxy = proxy;
+ }
+
public URL getLocation() {
StringBuilder queryStringBuilder = new StringBuilder();
@@ -367,7 +391,11 @@
responseHeaders.clear();
// Open a connection
- connection = (HttpURLConnection) location.openConnection();
+ if (proxy == null) {
+ connection = (HttpURLConnection) location.openConnection();
+ } else {
+ connection = (HttpURLConnection) location.openConnection(proxy);
+ }
connection.setRequestMethod(method.toString());
connection.setAllowUserInteraction(false);
connection.setInstanceFollowRedirects(false);