Skip to content

给httpJobHandler的参数传入添加登录验证功能 #3639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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