- 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/DownloadJob.java
r31878 r31880 107 107 private final String mode; 108 108 109 private String proxy_url; // only the main thread (where DownloadJob runs) modifies this, so no synching needed109 private Properties proxy_urls; // only the main thread (where DownloadJob runs) modifies this, so no synching needed 110 110 111 111 /** 112 112 */ 113 public DownloadJob(Download download, String proxy_pass, String proxy_user, DownloadScrollPane mummy, String mode, String proxy_url) {113 public DownloadJob(Download download, String proxy_pass, String proxy_user, DownloadScrollPane mummy, String mode, Properties proxy_urls) { 114 114 URL url = null; 115 115 int folder_hash; 116 116 117 this.proxy_url = proxy_url;117 this.proxy_urls = proxy_urls; 118 118 119 119 download_option = downloadToHashMap(download); … … 310 310 Process prcs = null; 311 311 312 if (proxy_url != null && !proxy_url.equals("")) {312 if (proxy_urls.size() != 0) { 313 313 // Specify proxies as environment variables 314 314 // Need to manually specify GSDLHOME and GSDLOS also 315 env = new String[4+proxy_urls.size()]; 315 316 316 proxy_url = proxy_url.replaceAll("http://",""); 317 318 env = new String[7]; 319 320 env[0] = "http_proxy=http://"+proxy_url; 321 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 322 // see also https://wiki.archlinux.org/index.php/proxy_settings 323 env[2] = "ftp_proxy=ftp://"+proxy_url; 324 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 325 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 317 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 318 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 326 319 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 327 env[ 5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc";320 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 328 321 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 329 322 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 330 323 // So make PATH available to get open3() working: 331 env[6] = "PATH="+System.getenv("PATH"); 324 env[3] = "PATH="+System.getenv("PATH"); 325 326 int next_index = 4; 327 String proxy_url = proxy_urls.getProperty("HTTP"); 328 if(proxy_url != null) { 329 env[next_index] = "http_proxy="+proxy_url; 330 next_index++; 331 } 332 proxy_url = proxy_urls.getProperty("HTTPS"); 333 if(proxy_url != null) { 334 env[next_index] = "https_proxy="+proxy_url; 335 next_index++; 336 } 337 proxy_url = proxy_urls.getProperty("FTP"); 338 if(proxy_url != null) { 339 env[next_index] = "ftp_proxy="+proxy_url; 340 next_index++; 341 } 332 342 333 343 prcs = rt.exec(cmd, env); … … 623 633 String [] env = null; 624 634 625 if (proxy_url != null && !proxy_url.equals("")) {635 if (proxy_urls.size() != 0) { 626 636 // Specify proxies as environment variables 627 637 // Need to manually specify GSDLHOME and GSDLOS also 638 env = new String[4+proxy_urls.size()]; 628 639 629 proxy_url = proxy_url.replaceAll("http://",""); 630 631 env = new String[7]; 632 633 env[0] = "http_proxy=http://"+proxy_url; 634 env[1] = "https_proxy=http://"+proxy_url; // yes, HTTP protocol for https:// too 635 // see also https://wiki.archlinux.org/index.php/proxy_settings 636 env[2] = "ftp_proxy=ftp://"+proxy_url; 637 env[3] = "GSDLHOME=" + Configuration.gsdl_path; 638 env[4] = "GSDLOS=" + Gatherer.client_operating_system; 640 env[0] = "GSDLHOME=" + Configuration.gsdl_path; 641 env[1] = "GSDLOS=" + Gatherer.client_operating_system; 639 642 // teach it where the wgetrc file lives, in gs2build/bin/<os>: 640 env[ 5] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc";643 env[2] = "WGETRC=" + LocalGreenstone.getBinOSDirectoryPath(Gatherer.client_operating_system)+"wgetrc"; 641 644 // Issue discovered on Windows: If PATH is not made available to perl, so that wget or something else needed by 642 645 // WgetDownload.pm's open3() call is not on the PATH, then the perl open() call to run wget fails. 643 646 // So make PATH available to get open3() working: 644 env[6] = "PATH="+System.getenv("PATH"); 647 env[3] = "PATH="+System.getenv("PATH"); 648 649 int next_index = 4; 650 String proxy_url = proxy_urls.getProperty("HTTP"); 651 if(proxy_url != null) { 652 env[next_index] = "http_proxy="+proxy_url; 653 next_index++; 654 } 655 proxy_url = proxy_urls.getProperty("HTTPS"); 656 if(proxy_url != null) { 657 env[next_index] = "https_proxy="+proxy_url; 658 next_index++; 659 } 660 proxy_url = proxy_urls.getProperty("FTP"); 661 if(proxy_url != null) { 662 env[next_index] = "ftp_proxy="+proxy_url; 663 next_index++; 664 } 645 665 646 666 prcs = new SafeProcess(cmd, env, null); 647 } 667 } 648 668 else if(Gatherer.isGsdlRemote && Gatherer.isDownloadEnabled && !Utility.isWindows()) { 649 669 // Not Windows, but running client with download panel
Note:
See TracChangeset
for help on using the changeset viewer.