Skip to content

Commit

Permalink
ssget updated to allow for redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed May 29, 2020
1 parent 51d622f commit 9bb3183
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
Binary file modified ssget/files/ss_index.mat
Binary file not shown.
9 changes: 7 additions & 2 deletions ssget/files/ssstats.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
2851
16-Jan-2019 14:21:19
2856
09-Oct-2019 16:31:17
HB,1138_bus,1138,1138,4054,1,0,0,1,1,1,power network problem,4054
HB,494_bus,494,494,1666,1,0,0,1,1,1,power network problem,1666
HB,662_bus,662,662,2474,1,0,0,1,1,1,power network problem,2474
Expand Down Expand Up @@ -2851,3 +2851,8 @@ Freescale,nxp1,414604,414604,2655880,1,0,0,0,0.9998398784682034,0.82205799966457
Martin,marine1,400320,400320,6226538,1,0,0,0,0.922267240944297,0,chemical oceanography problem,6226538
Negre,dendrimer,730,730,63024,1,0,0,0,1,1,computational chemistry problem,63024
Precima,analytics,303813,303813,2006126,1,0,0,0,1,1,data analytics problem,2006126
GAP,GAP-twitter,61578415,61578415,1468364884,1,0,0,0,0.3621059600332965,0.001422518355458029,directed weighted graph,1468364884
GAP,GAP-web,50636151,50636151,1930292948,1,0,0,0,0.1245713694644861,0.0004892386935249789,directed weighted graph,1930292948
GAP,GAP-road,23947347,23947347,57708624,1,0,0,0,1,1,directed weighted graph,57708624
GAP,GAP-kron,134217726,134217726,4223264644,1,0,0,0,1,1,random undirected weighted graph,4223264644
GAP,GAP-urand,134217728,134217728,4294966740,1,0,0,0,1,1,random undirected weighted graph,4294966740
Binary file modified ssget/ssgui.jar
Binary file not shown.
32 changes: 27 additions & 5 deletions ssget/ssgui.java
Original file line number Diff line number Diff line change
Expand Up @@ -2261,8 +2261,28 @@ private void download_file (String filename)

try
{
// Follow redirects manually
int max_redirects = 5;
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

for(int redirect_count = 0; redirect_count < max_redirects; redirect_count++)
{
int status = conn.getResponseCode();
if (status >= 300 && status <= 308)
{
// Redirecting
String loc = conn.getHeaderField("Location");
url = new URL(loc);
conn = (HttpURLConnection) url.openConnection();
}
else
{
break;
}
}

// determine the file size (fails for files > 2GB)
int len = url.openConnection ( ).getContentLength ( ) ;
int len = conn.getContentLength();

// start the progress bar
if (gui_ready)
Expand Down Expand Up @@ -2291,7 +2311,8 @@ private void download_file (String filename)
}

// open the source and destination files
url_in = new BufferedInputStream (url.openStream ( )) ;
//url_in = new BufferedInputStream (url.openStream ( )) ;
url_in = new BufferedInputStream (conn.getInputStream()) ;
ftemp_out = new BufferedOutputStream (new FileOutputStream
(fix_name (ftemp_name)), buffersize) ;

Expand All @@ -2318,9 +2339,10 @@ private void download_file (String filename)
}
catch (Exception e)
{
// display warning dialog
JOptionPane.showMessageDialog (this, "Download failed: "
+ urlstring, "Warning", JOptionPane.WARNING_MESSAGE) ;
if (debug)
{
System.out.println("Download failed: " + urlstring);
}
ok = false ;
}

Expand Down

0 comments on commit 9bb3183

Please sign in to comment.