Hisoka-X commented on code in PR #8434:
URL: https://github.com/apache/seatunnel/pull/8434#discussion_r1919778406


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/Options.java:
##########
@@ -124,6 +124,14 @@ public TypedOptionBuilder<Map<String, String>> mapType() {
             return new TypedOptionBuilder<>(key, new TypeReference<Map<String, 
String>>() {});
         }
 
+        /**
+         * Defines that the value of the option should be a set of properties, 
which can be
+         * represented as {@code Map<String, String>}.

Review Comment:
   ```suggestion
            * represented as {@code Map<String, Object>}.
   ```



##########
seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProvider.java:
##########
@@ -115,14 +119,36 @@ public HttpResponse execute(
             String method,
             Map<String, String> headers,
             Map<String, String> params,
-            String body)
+            Map<String, Object> body,
+            Map<String, Object> pageParams,
+            boolean keepParamsForm)
             throws Exception {
         // convert method option to uppercase
         method = method.toUpperCase(Locale.ROOT);
-        if (HttpPost.METHOD_NAME.equals(method)) {
+        // Keep the original post  logic
+        if (HttpPost.METHOD_NAME.equals(method) && keepParamsForm) {
+            if (MapUtils.isEmpty(params)) {
+                params = new HashMap<>();
+            }
+            if (MapUtils.isNotEmpty(pageParams)) {
+                for (Map.Entry<String, Object> entry : pageParams.entrySet()) {
+                    params.put(entry.getKey(), entry.getValue().toString());
+                }
+            }
             return doPost(url, headers, params, body);

Review Comment:
   Please reuse 
https://github.com/apache/seatunnel/pull/8434/files#diff-84c2e7b09f0d771042057899d626749a07479adaa72a7db60d17ed0ec3592448R328



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf:
##########
@@ -25,7 +25,7 @@ source {
     plugin_output = "http"
     url = "http://mockserver:1080/example/jsonBody";
     method = "POST"
-    body="{"id":1}"
+    body={"id":1}

Review Comment:
   I think we should keep body parameter as old way. Use string not map.



##########
seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProvider.java:
##########
@@ -115,14 +119,36 @@ public HttpResponse execute(
             String method,
             Map<String, String> headers,
             Map<String, String> params,
-            String body)
+            Map<String, Object> body,
+            Map<String, Object> pageParams,
+            boolean keepParamsForm)

Review Comment:
   ```suggestion
               boolean keepParamsAsForm)
   ```



##########
seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/client/HttpClientProvider.java:
##########
@@ -429,6 +481,56 @@ private void addHeaders(HttpRequestBase request, 
Map<String, String> headers) {
         headers.forEach(request::addHeader);
     }
 
+    private void addBody(
+            HttpEntityEnclosingRequestBase request,
+            Map<String, Object> body,
+            Map<String, Object> pageParams)
+            throws UnsupportedEncodingException {
+        Map<String, Object> bodyMap = new HashedMap<>();
+        if (MapUtils.isNotEmpty(body)) {
+            bodyMap = body;
+        }
+
+        if (request.getHeaders(HTTP.CONTENT_TYPE) != null
+                && request.getHeaders(HTTP.CONTENT_TYPE).length > 0
+                && APPLICATION_FORM.equalsIgnoreCase(
+                        request.getHeaders(HTTP.CONTENT_TYPE)[0].getValue())) {

Review Comment:
   Please add test case to cover this logic. And update the docs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to