Skip to content

Commit

Permalink
Merge pull request #1 from MQMMMQM/MQMMMQM-patch-Update-SampleXxlJob.…
Browse files Browse the repository at this point in the history
…java-httpJobHandler添加登录验证参数

Update SampleXxlJob.java httpJobHandler添加登录验证参数
  • Loading branch information
MQMMMQM authored Jan 23, 2025
2 parents 7ad6c7b + 33640bc commit 24d3899
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ public void httpJobHandler() throws Exception {
String url;
String method;
String data;
String auth;
try {
Map<String, String> paramMap =GsonTool.fromJson(param, Map.class);
url = paramMap.get("url");
method = paramMap.get("method");
data = paramMap.get("data");
auth = paramMap.get("auth");
} catch (Exception e) {
XxlJobHelper.log(e);
XxlJobHelper.handleFail();
Expand Down Expand Up @@ -203,7 +205,10 @@ public void httpJobHandler() throws Exception {
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");

if (auth != null) {
connection.setRequestProperty("Authorization", "Basic " + auth);
}

// do connection
connection.connect();

Expand Down

0 comments on commit 24d3899

Please sign in to comment.