This is an automated email from the ASF dual-hosted git repository.
gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 8a22797bc [fix] Only POST and PUT methods carry payload (#3814)
8a22797bc is described below
commit 8a22797bcaee5cc07ed1411ae7839de66fedd2c7
Author: Duansg <[email protected]>
AuthorDate: Tue Oct 14 21:51:50 2025 +0800
[fix] Only POST and PUT methods carry payload (#3814)
Co-authored-by: Tomsun28 <[email protected]>
---
.../collector/collect/prometheus/PrometheusAutoCollectImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/prometheus/PrometheusAutoCollectImpl.java
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/prometheus/PrometheusAutoCollectImpl.java
index 5ab95579d..8fa199691 100644
---
a/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/prometheus/PrometheusAutoCollectImpl.java
+++
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/prometheus/PrometheusAutoCollectImpl.java
@@ -65,6 +65,7 @@ import org.apache.http.impl.auth.DigestScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.protocol.HttpContext;
+import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
@@ -276,7 +277,7 @@ public class PrometheusAutoCollectImpl implements
PrometheusCollect {
}
// if it has payload, would override post params
- if (StringUtils.hasLength(protocol.getPayload())) {
+ if (StringUtils.hasLength(protocol.getPayload()) &&
(HttpMethod.POST.matches(protocol.getMethod()) ||
HttpMethod.PUT.matches(protocol.getMethod()))) {
requestBuilder.setEntity(new StringEntity(protocol.getPayload(),
StandardCharsets.UTF_8));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]