Commit d3a0d9e0 by shenjinzhu

url检测加了user-Agent

parent ae775239
...@@ -45,6 +45,8 @@ public class Task implements Runnable { ...@@ -45,6 +45,8 @@ public class Task implements Runnable {
url = new URL(ping.getPingUrlOne()); url = new URL(ping.getPingUrlOne());
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(1000 * 10); conn.setConnectTimeout(1000 * 10);
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36");
int code = conn.getResponseCode(); int code = conn.getResponseCode();
if (code > 399 || code < 200) { if (code > 399 || code < 200) {
Template tp = MainThread.mainMap.get(ping.getTemplateId()); Template tp = MainThread.mainMap.get(ping.getTemplateId());
...@@ -82,6 +84,8 @@ public class Task implements Runnable { ...@@ -82,6 +84,8 @@ public class Task implements Runnable {
try { try {
url = new URL(ping.getPingUrlTwo()); url = new URL(ping.getPingUrlTwo());
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36");
conn.setConnectTimeout(1000 * 10); conn.setConnectTimeout(1000 * 10);
int code = conn.getResponseCode(); int code = conn.getResponseCode();
if (code != 200) { if (code != 200) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment