MCPcopy Create free account
hub / github.com/1150037361/SpringScan / doGet

Method doGet

src/main/java/util/HttpUtil.java:12–53  ·  view source on GitHub ↗
(String url)

Source from the content-addressed store, hash-verified

10public class HttpUtil {
11
12 public static String doGet(String url) {
13 StringBuilder result = new StringBuilder();
14 HttpURLConnection conn = null;
15 BufferedReader br = null;
16 String content;
17
18 try {
19 URL u = new URL(url);
20 conn = (HttpURLConnection) u.openConnection();
21 conn.setRequestMethod("GET");
22 conn.setConnectTimeout(60000);
23 conn.setReadTimeout(60000);
24 conn.setRequestProperty("Accept", "*/*");
25 conn.setRequestProperty("Connection", "close");
26 conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36");
27 conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
28
29 if (conn.getResponseCode() == 200){
30 br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"utf-8"));
31 while ((content = br.readLine()) != null){
32 result.append(content);
33 }
34 }
35
36 } catch (MalformedURLException e) {
37 e.printStackTrace();
38 } catch (IOException e) {
39 e.printStackTrace();
40 } finally {
41 if (br != null){
42 try {
43 br.close();
44 } catch (IOException e) {
45 e.printStackTrace();
46 }
47 }
48 if (conn != null){
49 conn.disconnect();
50 }
51 }
52 return result.toString();
53 }
54}

Callers 1

scanBurpApiMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected