Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Set proxy and port if passed as VM param #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down