diff --git a/java-mapi-wrapper/src/com/brightcove/mediaapi/wrapper/WriteApi.java b/java-mapi-wrapper/src/com/brightcove/mediaapi/wrapper/WriteApi.java index 19c4564..73381b4 100755 --- a/java-mapi-wrapper/src/com/brightcove/mediaapi/wrapper/WriteApi.java +++ b/java-mapi-wrapper/src/com/brightcove/mediaapi/wrapper/WriteApi.java @@ -257,7 +257,17 @@ private JSONObject executeCommand(JSONObject json, File file) throws BrightcoveE String buffer; try{ HttpClient httpAgent = clientFactory.getHttpClient(); - response = httpAgent.execute(method); + + //Set proxy and port if passed as VM param + String proxyHost = System.getProperty("http.proxyHost") != null?System.getProperty("http.proxyHost"):null; + int proxyPort = System.getProperty("http.proxyPort") != null?Integer.parseInt(System.getProperty("http.proxyPort")):80; + HttpHost proxy = null; + if (proxyHost!=null) { + proxy = new HttpHost(proxyHost, proxyPort); + httpAgent.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); + } + + response = httpAgent.execute(method); // Make sure the HTTP communication was OK (not the same as an error in the Media API reponse) Integer statusCode = response.getStatusLine().getStatusCode();