diff --git a/src/ExtraInfoDownloader.java b/src/ExtraInfoDownloader.java index 6ab7143..d8f6719 100644 --- a/src/ExtraInfoDownloader.java +++ b/src/ExtraInfoDownloader.java @@ -10,20 +10,28 @@ public class ExtraInfoDownloader { + authority + "... "); Stack extraInfos = new Stack(); for (String fingerprint : directories.keySet()) { - BufferedInputStream in = new BufferedInputStream(new URL( - "http://" + authority + "/tor/extra/fp/" + fingerprint). - openStream()); - StringBuilder sb = new StringBuilder(); - int len; - byte[] data = new byte[1024]; - while ((len = in.read(data, 0, 1024)) >= 0) { - sb.append(new String(data, 0, len)); - } - in.close(); - String extraInfo = sb.toString(); - if (extraInfo.length() > 0) { - BufferedReader br = new BufferedReader(new StringReader(extraInfo)); - rdp.parse(br); + URL u = new URL("http://" + authority + "/tor/extra/fp/" + + fingerprint); + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.setRequestMethod("GET"); + huc.connect(); + int response = huc.getResponseCode(); + if (response == 200) { + BufferedInputStream in = new BufferedInputStream( + huc.getInputStream()); + StringBuilder sb = new StringBuilder(); + int len; + byte[] data = new byte[1024]; + while ((len = in.read(data, 0, 1024)) >= 0) { + sb.append(new String(data, 0, len)); + } + in.close(); + String extraInfo = sb.toString(); + if (extraInfo.length() > 0) { + BufferedReader br = new BufferedReader( + new StringReader(extraInfo)); + rdp.parse(br); + } } } System.out.println("done");