From 17b416ca070d13ee567a4963592873eea80f3ef1 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Thu, 11 Jun 2020 10:20:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8HTTP=E4=BB=BB=E5=8A=A1Handler?= =?UTF-8?q?=EF=BC=88httpJobHandler=EF=BC=89=E4=BC=98=E5=8C=96=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20"setDoOutput(true)"=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AF=B7=E6=B1=82GetMethod=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/frameless/jobhandler/HttpJobHandler.java | 5 +++-- .../executor/sample/jboot/jobhandler/HttpJobHandler.java | 7 ++++--- .../executor/sample/jfinal/jobhandler/HttpJobHandler.java | 5 +++-- .../executor/sample/nutz/jobhandler/HttpJobHandler.java | 5 +++-- .../xxl/job/executor/service/jobhandler/SampleXxlJob.java | 5 +++-- .../xxl/job/executor/service/jobhandler/SampleXxlJob.java | 5 +++-- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java index eeb8e3cd..ea44695e 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java @@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); // request HttpURLConnection connection = null; @@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush(); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java index 08a5d015..68a27b39 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-jboot/src/main/java/com/xuxueli/executor/sample/jboot/jobhandler/HttpJobHandler.java @@ -51,8 +51,9 @@ public class HttpJobHandler extends IJobHandler { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); - // request + // request HttpURLConnection connection = null; BufferedReader bufferedReader = null; try { @@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush(); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java index 414d8e25..ae1dbb65 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java @@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); // request HttpURLConnection connection = null; @@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush(); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java index c09dd590..837000be 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java @@ -51,6 +51,7 @@ public class HttpJobHandler extends IJobHandler { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); // request HttpURLConnection connection = null; @@ -62,7 +63,7 @@ public class HttpJobHandler extends IJobHandler { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -75,7 +76,7 @@ public class HttpJobHandler extends IJobHandler { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush(); diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java index bde06693..666d2d3e 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java @@ -151,6 +151,7 @@ public class SampleXxlJob { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); // request HttpURLConnection connection = null; @@ -162,7 +163,7 @@ public class SampleXxlJob { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -175,7 +176,7 @@ public class SampleXxlJob { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush(); 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 bde06693..666d2d3e 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 @@ -151,6 +151,7 @@ public class SampleXxlJob { XxlJobLogger.log("method["+ method +"] invalid."); return ReturnT.FAIL; } + boolean isPostMethod = method.equals("POST"); // request HttpURLConnection connection = null; @@ -162,7 +163,7 @@ public class SampleXxlJob { // connection setting connection.setRequestMethod(method); - connection.setDoOutput(true); + connection.setDoOutput(isPostMethod); connection.setDoInput(true); connection.setUseCaches(false); connection.setReadTimeout(5 * 1000); @@ -175,7 +176,7 @@ public class SampleXxlJob { connection.connect(); // data - if (data!=null && data.trim().length()>0) { + if (isPostMethod && data!=null && data.trim().length()>0) { DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream()); dataOutputStream.write(data.getBytes("UTF-8")); dataOutputStream.flush();