- Timestamp:
- 2017-08-14T22:23:04+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/download/ServerInfoDialog.java
r31878 r31880 8 8 import java.io.*; 9 9 import java.util.ArrayList; 10 import java.util.Properties; 10 11 import org.greenstone.gatherer.cdm.Argument; 11 12 import org.greenstone.gatherer.Configuration; … … 27 28 private JDialog info_dialog; 28 29 private Download download; 29 private String proxy_url;30 private Properties proxy_urls; 30 31 31 public ServerInfoDialog(String url, String proxy_url, String mode, Download download) {32 public ServerInfoDialog(String url, Properties proxy_urls, String mode, Download download) { 32 33 super(); 33 34 this.url = url; 34 35 this.mode = mode; 35 36 this.download = download; 36 this.proxy_url = proxy_url;37 this.proxy_urls = proxy_urls; 37 38 this.info_dialog = this; 38 39 … … 106 107 try { 107 108 SafeProcess prcs = null; 108 109 if (proxy_url != null && !proxy_url.equals("")) { 110 // Specify proxies as environment variables 111 // Need to manually specify GSDLHOME and GSDLOS also 112 113 proxy_url = proxy_url.replaceAll("http://",""); 114 115 String [] env = new String[7]; 116 117 env[0] = "http_proxy=http://"+proxy_url; 118 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 119 // see also https://wiki.archlinux.org/index.php/proxy_settings 120 env[2] = "ftp_proxy=ftp://"+proxy_url; 121 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 122 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 123 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 124 env[5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 125 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 126 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 127 // So make PATH available to get open3() working: 128 env[6] = "PATH="+System.getenv("PATH"); 129 130 prcs = new SafeProcess(command, env, null); 131 } 132 else { 133 // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 134 prcs = new SafeProcess(command); 109 110 if (proxy_urls.size() != 0) { 111 // Specify proxies as environment variables 112 // Need to manually specify GSDLHOME and GSDLOS also 113 String[] env = new String[4+proxy_urls.size()]; 114 115 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 116 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 117 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 118 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 119 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 120 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 121 // So make PATH available to get open3() working: 122 env[3] = "PATH="+System.getenv("PATH"); 123 124 int next_index = 4; 125 String proxy_url = proxy_urls.getProperty("HTTP"); 126 if(proxy_url != null) { 127 env[next_index] = "http_proxy="+proxy_url; 128 next_index++; 135 129 } 130 proxy_url = proxy_urls.getProperty("HTTPS"); 131 if(proxy_url != null) { 132 env[next_index] = "https_proxy="+proxy_url; 133 next_index++; 134 } 135 proxy_url = proxy_urls.getProperty("FTP"); 136 if(proxy_url != null) { 137 env[next_index] = "ftp_proxy="+proxy_url; 138 next_index++; 139 } 140 141 prcs = new SafeProcess(command, env, null); 142 } else { 143 // Will inherit the GLI's environment, with GSDLHOME and GSDLOS set 144 prcs = new SafeProcess(command); 145 } 136 146 137 147 // special processing of Process' stderr stream:
Note:
See TracChangeset
for help on using the changeset viewer.