diff --git a/docs/en/connector-v2/sink/Http.md b/docs/en/connector-v2/sink/Http.md index 099943ce86e..55a69e93334 100644 --- a/docs/en/connector-v2/sink/Http.md +++ b/docs/en/connector-v2/sink/Http.md @@ -36,7 +36,6 @@ They can be downloaded via install-plugin.sh or from the Maven central repositor |-----------------------------|--------|----------|---------|-----------------------------------------------------------------------------------------------------| | url | String | Yes | - | Http request url | | headers | Map | No | - | Http headers | -| params | Map | No | - | Http params | | retry | Int | No | - | The max retry times if request http return to `IOException` | | retry_backoff_multiplier_ms | Int | No | 100 | The retry-backoff times(millis) multiplier if request http failed | | retry_backoff_max_ms | Int | No | 10000 | The maximum retry-backoff times(millis) if request http failed | diff --git a/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java b/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java index 0d961f711ce..8411001fff8 100644 --- a/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java +++ b/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java @@ -36,7 +36,6 @@ public OptionRule optionRule() { return OptionRule.builder() .required(HttpConfig.URL) .optional(HttpConfig.HEADERS) - .optional(HttpConfig.PARAMS) .optional(HttpConfig.RETRY) .optional(HttpConfig.RETRY_BACKOFF_MULTIPLIER_MS) .optional(HttpConfig.RETRY_BACKOFF_MAX_MS) diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java index 402abd5915e..d65617bb555 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java @@ -135,6 +135,16 @@ public void testSourceToAssertSink(TestContainer container) Container.ExecResult execResult12 = container.executeJob("/http_multilinejson_to_assert.conf"); Assertions.assertEquals(0, execResult12.getExitCode()); + + // http httpFormRequestbody + Container.ExecResult execResult13 = + container.executeJob("/http_formrequestbody_to_assert.conf"); + Assertions.assertEquals(0, execResult13.getExitCode()); + + // http httpJsonRequestBody + Container.ExecResult execResult14 = + container.executeJob("/http_jsonrequestbody_to_assert.conf"); + Assertions.assertEquals(0, execResult14.getExitCode()); } public String getMockServerConfig() { diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf new file mode 100644 index 00000000000..facebc81ef8 --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf @@ -0,0 +1,85 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +env { + execution.parallelism = 1 + job.mode = "BATCH" +} + +source { + Http { + result_table_name = "http" + url = "http://mockserver:1080/example/formBody" + method = "POST" + params ={id = 1} + format = "json" + schema = { + fields { + name = string + age = int + } + } + } +} + +sink { + Console { + source_table_name = "http" + } + Assert { + source_table_name = "http" + rules { + row_rules = [ + { + rule_type = MAX_ROW + rule_value = 2 + }, + { + rule_type = MIN_ROW + rule_value = 2 + } + ], + field_rules = [ + { + field_name = name + field_type = string + field_value = [ + { + rule_type = NOT_NULL + } + ] + }, + { + field_name = age + field_type = int + field_value = [ + { + rule_type = NOT_NULL + } + ] + } + ] + } + } + Http { + source_table_name = "http" + url = "http://mockserver:1080/example/webhook" + headers { + token = "9e32e859ef044462a257e1fc76730066" + } + } +} \ No newline at end of file diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf new file mode 100644 index 00000000000..5fde4d48729 --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf @@ -0,0 +1,85 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +env { + execution.parallelism = 1 + job.mode = "BATCH" +} + +source { + Http { + result_table_name = "http" + url = "http://mockserver:1080/example/jsonBody" + method = "POST" + body="{"id":1}" + format = "json" + schema = { + fields { + name = string + age = int + } + } + } +} + +sink { + Console { + source_table_name = "http" + } + Assert { + source_table_name = "http" + rules { + row_rules = [ + { + rule_type = MAX_ROW + rule_value = 2 + }, + { + rule_type = MIN_ROW + rule_value = 2 + } + ], + field_rules = [ + { + field_name = name + field_type = string + field_value = [ + { + rule_type = NOT_NULL + } + ] + }, + { + field_name = age + field_type = int + field_value = [ + { + rule_type = NOT_NULL + } + ] + } + ] + } + } + Http { + source_table_name = "http" + url = "http://mockserver:1080/example/webhook" + headers { + token = "9e32e859ef044462a257e1fc76730066" + } + } +} \ No newline at end of file diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json index 622c4a1d9f9..2c419277e04 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json @@ -4447,5 +4447,84 @@ ] } } + }, + { + "httpRequest": { + "method" : "POST", + "path": "/example/jsonBody", + "body": { + "type": "JSON", + "json": { + "id": 1 + }, + "matchType": "STRICT" + } + }, + "httpResponse": { + "body": [ + { + "name": "lzl", + "age": 18 + }, + { + "name": "pizz", + "age": 19 + } + ], + "headers": { + "Content-Type": "application/json" + } + } + }, + { + "httpRequest": { + "path": "/example/formBody", + "method": "POST", + "body": { + "type": "PARAMETERS", + "parameters": { + "id": "1" + } + } + }, + "httpResponse": { + "body": [ + { + "name": "lzl", + "age": 18 + }, + { + "name": "pizz", + "age": 19 + } + ], + "headers": { + "Content-Type": "application/json" + } + } + }, + { + "httpRequest": { + "path": "/example/webhook", + "method": "POST", + "headers": { + "token": ["9e32e859ef044462a257e1fc76730066"] + } + }, + "httpResponse": { + "body": [ + { + "name": "lzl", + "age": 18 + }, + { + "name": "pizz", + "age": 19 + } + ], + "headers": { + "Content-Type": "application/json" + } + } } ]