com.networknt.aws.lambda.HttpUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of custom-runtime Show documentation
Show all versions of custom-runtime Show documentation
A custom runtime for GraalVM native image to improve code start performance
The newest version!
package com.networknt.aws.lambda;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUtils {
public static HttpURLConnection get(String endpoint) throws IOException {
URL url = new URL(endpoint);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
// Execute HTTP Call
connection.getResponseCode();
return connection;
}
public static HttpURLConnection post(String endpoint, String message) throws IOException {
URL url = new URL(endpoint);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(message);
out.flush();
out.close();
// Execute HTTP Call
connection.getResponseCode();
return connection;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy