From caf1b5add35d20afe158e09a0cead611c9a4a733 Mon Sep 17 00:00:00 2001 From: gselva Date: Thu, 2 Aug 2012 21:12:17 +0100 Subject: [PATCH] Set proxy and port if passed as VM param --- .../com/brightcove/mediaapi/wrapper/WriteApi.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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();