Mercurial > hg > LGServices
comparison src/main/java/de/mpiwg/gazetteer/utils/HTTPUtils.java @ 4:c30ff4f27ec3
adding developer guide documentation
author | "jurzua <jurzua@mpiwg-berlin.mpg.de>" |
---|---|
date | Mon, 18 May 2015 15:55:01 +0200 |
parents | 3e62083dbcbf |
children | 3b3e2963c8f7 |
comparison
equal
deleted
inserted
replaced
3:7ffaefcee5b5 | 4:c30ff4f27ec3 |
---|---|
96 in.close(); | 96 in.close(); |
97 | 97 |
98 return sb.toString(); | 98 return sb.toString(); |
99 } | 99 } |
100 | 100 |
101 public static HttpStringResponse getStringResponse(String link) throws IOException, KeyManagementException, NoSuchAlgorithmException{ | 101 public static HttpStringResponse getStringResponse(String url) throws IOException, KeyManagementException, NoSuchAlgorithmException{ |
102 if(link.startsWith("https") || link.startsWith("HTTPS")) | 102 if(url.startsWith("https") || url.startsWith("HTTPS")) |
103 return getHttpSSLStringResponse(link); | 103 return getHttpSSLStringResponse(url); |
104 return getHttpStringResponse(link); | 104 return getHttpStringResponse(url); |
105 } | 105 } |
106 | 106 |
107 private static HttpStringResponse getHttpSSLStringResponse(String link) throws IOException, KeyManagementException, NoSuchAlgorithmException{ | 107 private static HttpStringResponse getHttpSSLStringResponse(String link) throws IOException, KeyManagementException, NoSuchAlgorithmException{ |
108 | 108 |
109 // Install the all-trusting trust manager | 109 // Install the all-trusting trust manager |
138 return new HttpStringResponse(httpConn.getResponseCode(), sb.toString()); | 138 return new HttpStringResponse(httpConn.getResponseCode(), sb.toString()); |
139 } | 139 } |
140 | 140 |
141 private static HttpStringResponse getHttpStringResponse(String link) throws IOException{ | 141 private static HttpStringResponse getHttpStringResponse(String link) throws IOException{ |
142 | 142 |
143 //System.out.println(link); | 143 //System.out.println(url); |
144 | 144 |
145 URL url = new URL(link); | 145 URL url = new URL(link); |
146 HttpURLConnection httpConn = (HttpURLConnection)url.openConnection(); | 146 HttpURLConnection httpConn = (HttpURLConnection)url.openConnection(); |
147 | 147 |
148 BufferedReader in = null; | 148 BufferedReader in = null; |