From 53ce8de426561e7a43847afda23b5e24e6f76c4e Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 19 一月 2026 17:29:55 +0800
Subject: [PATCH] 2026.1.19 1. 新增可配置的台账提交期限 2. 新增可配置的自巡查承诺
---
src/main/kotlin/cn/flightfeather/supervision/common/net/HttpMethod.kt | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/net/HttpMethod.kt b/src/main/kotlin/cn/flightfeather/supervision/common/net/HttpMethod.kt
index c526c76..f905a2c 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/common/net/HttpMethod.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/common/net/HttpMethod.kt
@@ -6,6 +6,8 @@
import org.apache.commons.httpclient.methods.PostMethod
import org.apache.commons.httpclient.methods.StringRequestEntity
import org.apache.commons.httpclient.protocol.Protocol
+import org.apache.http.client.methods.HttpPost
+import org.slf4j.LoggerFactory
/**
* @author riku
@@ -14,6 +16,7 @@
class HttpMethod(
private val host: String, private val port: Int, private val isHttps: Boolean = false
) {
+ private val logger = LoggerFactory.getLogger(HttpMethod::class.java)
data class MyResponse(
val success: Boolean,
@@ -27,6 +30,7 @@
private val httpClient = HttpClient()
init {
+ Protocol.registerProtocol("https", Protocol("https", SkipCertificateValidation.MySecureProtocolSocketFactory(), port))
if (isHttps) {
httpClient.hostConfiguration.setHost(host, port, Protocol.getProtocol("https"))
} else {
@@ -65,17 +69,25 @@
postMethod.requestEntity = StringRequestEntity(data, "application/json", "utf-8")
}
- return when (httpClient.executeMethod(postMethod)) {
- 200 -> MyResponse(true, postMethod)
- else -> MyResponse(false, postMethod)
+ return try {
+ when (httpClient.executeMethod(postMethod)) {
+ 200 -> MyResponse(true, postMethod)
+ else -> MyResponse(false, postMethod)
+ }
+ } catch (e: Exception) {
+ logger.error(e.message)
+ MyResponse(false, postMethod)
}
}
private fun defaultConfig(method: HttpMethodBase) {
- method.setRequestHeader("accept", "*/*");
- method.setRequestHeader("connection", "Keep-Alive");
- method.setRequestHeader("Accept-Language", "zh-cn,zh;q=0.5");
- method.setRequestHeader("Content-Type", "application/json;charset=utf-8")
+ method.setRequestHeader("Accept", "*/*");
+ method.setRequestHeader("Connection", "Keep-Alive");
+// method.setRequestHeader("Accept-Language", "zh-cn,zh;q=0.5");
+ method.setRequestHeader("Accept-Encoding", "gzip,deflate,br");
+// method.setRequestHeader("Content-Type", "application/json;charset=utf-8")
+ method.setRequestHeader("Content-Type", "application/json")
+// method.setRequestHeader("Content-Type", "application/json;charset=GBK")
}
}
\ No newline at end of file
--
Gitblit v1.9.3