diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java index c6fbf6654..976021164 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java @@ -158,11 +158,13 @@ public void httpJobHandler() throws Exception { String url; String method; String data; + String auth; try { Map 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(); @@ -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();