Dreaouth commented on a change in pull request #622:
URL: https://github.com/apache/rocketmq-externals/pull/622#discussion_r470607492
##########
File path:
rocketmq-connect/rocketmq-connect-runtime/src/main/java/org/apache/rocketmq/connect/runtime/rest/RestSender.java
##########
@@ -0,0 +1,38 @@
+package org.apache.rocketmq.connect.runtime.rest;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.net.URLEncoder;
+
+public class RestSender {
+ public String sendHttpRequest(String baseUrl, String configs){
+ try {
+ CloseableHttpClient client = null;
+ CloseableHttpResponse response = null;
+ try {
+ String encoded_configs = URLEncoder.encode(configs,"utf-8");
+ HttpGet httpGet = new HttpGet(baseUrl + encoded_configs);
+ client = HttpClients.createDefault();
+ response = client.execute(httpGet);
+ HttpEntity entity = response.getEntity();
+ String result = EntityUtils.toString(entity);
+ System.out.println(result);
+ return result;
+ } finally {
+ if (response != null) {
+ response.close();
+ }
+ if (client != null) {
+ client.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+}
Review comment:
Updated all
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]