Package com.santaba.agent.groovyapi.http
Class HTTP
- java.lang.Object
-
- com.santaba.agent.groovyapi.http.HTTP
-
public class HTTP extends java.lang.Object
This class provides functions to do HTTP related operations. We will try to extract http related credentials from the hostProps if existed.
The following properties may be used:
property name property note http.user / httpuser the username for basic authentication http.pass / httppass the password for basic authentication
-
-
Constructor Summary
Constructors Constructor Description HTTP()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
body(java.lang.String url)
do an HTTP GET on the provided url and return only the HTTP bodystatic java.lang.String
body(java.lang.String url, java.lang.String username, java.lang.String password)
do an HTTP GET on the provided url and return only the HTTP bodystatic java.lang.String
delete(java.lang.String url, java.lang.String data)
do an HTTP DELETE to the provided url and return the entire responsestatic java.lang.String
delete(java.lang.String url, java.lang.String data, java.util.Map headers)
do an HTTP DELETE to the provided url and return the entire responsestatic java.lang.String
delete(java.lang.String url, java.util.Map headers)
do an HTTP DELETE to the provided url and return the entire responsestatic java.lang.String
get(java.lang.String url)
do an HTTP GET on the provided url and return the entire HTTP responsestatic java.lang.String
get(java.lang.String url, java.lang.String username, java.lang.String password)
do an HTTP GET on the provided url and return the entire HTTP responsestatic java.lang.String
get(java.lang.String url, java.lang.String username, java.lang.String password, java.util.Map headers)
do an HTTP GET on the provided url and return the entire HTTP responsestatic java.lang.String
get(java.lang.String url, java.util.Map headers)
do an HTTP GET on the provided url and return the entire HTTP responsestatic java.lang.String
headers(java.lang.String url)
do an HTTP GET on the provided url and return only the HTTP headersstatic java.lang.String
headers(java.lang.String url, java.lang.String username, java.lang.String password)
do an HTTP GET on the provided url and return only the HTTP headersstatic Client
open(java.lang.String host, int port)
instantiate a non-ssl HTTP session object for use across multiple HTTP transactions
Will try to extract http credentials from the related hostProps if existedstatic Client
open(java.lang.String host, int port, boolean ssl)
instantiate an HTTP session object for use across multiple HTTP transactions
Will try to extract http credentials from the related hostProps if existedstatic java.lang.String
post(java.lang.String url, java.lang.String data)
do an HTTP POST to the provided url and return the entire responsestatic java.lang.String
post(java.lang.String url, java.lang.String data, java.util.Map headers)
do an HTTP POST to the provided url and return the entire responsestatic java.lang.String
put(java.lang.String url, java.lang.String data)
do an HTTP PUT to the provided url and return the entire responsestatic java.lang.String
put(java.lang.String url, java.lang.String data, java.util.Map headers)
do an HTTP PUT to the provided url and return the entire response
-
-
-
Method Detail
-
open
public static Client open(java.lang.String host, int port) throws java.io.IOException
instantiate a non-ssl HTTP session object for use across multiple HTTP transactions
Will try to extract http credentials from the related hostProps if existed- Parameters:
host
- The url of http hostport
- The host http port- Returns:
- Http client
- Throws:
java.io.IOException
- If some other I/O error occurs
-
open
public static Client open(java.lang.String host, int port, boolean ssl) throws java.io.IOException
instantiate an HTTP session object for use across multiple HTTP transactions
Will try to extract http credentials from the related hostProps if existed- Parameters:
host
- The url of http hostport
- The host http portssl
- Is this a ssl connection- Returns:
- Http client
- Throws:
java.io.IOException
- If some other I/O error occurs
-
get
public static java.lang.String get(java.lang.String url) throws java.io.IOException
do an HTTP GET on the provided url and return the entire HTTP response- Parameters:
url
- The url of http host- Returns:
- This url content
- Throws:
java.io.IOException
- If some other I/O error occurs
-
get
public static java.lang.String get(java.lang.String url, java.util.Map headers) throws java.io.IOException
do an HTTP GET on the provided url and return the entire HTTP response- Parameters:
url
- The url of http hostheaders
- The http header with this http request- Returns:
- This url content
- Throws:
java.io.IOException
- If some other I/O error occurs
-
get
public static java.lang.String get(java.lang.String url, java.lang.String username, java.lang.String password) throws java.io.IOException
do an HTTP GET on the provided url and return the entire HTTP response- Parameters:
url
- The url of http hostusername
- This http host's usernamepassword
- This http host's password- Returns:
- This url content
- Throws:
java.io.IOException
- If some other I/O error occurs
-
get
public static java.lang.String get(java.lang.String url, java.lang.String username, java.lang.String password, java.util.Map headers) throws java.io.IOException
do an HTTP GET on the provided url and return the entire HTTP response- Parameters:
url
- The url of http hostusername
- This http host's usernamepassword
- This http host's passwordheaders
- The http header with this http request- Returns:
- This url content
- Throws:
java.io.IOException
- If some other I/O error occurs
-
headers
public static java.lang.String headers(java.lang.String url) throws java.io.IOException
do an HTTP GET on the provided url and return only the HTTP headers- Parameters:
url
- Http url- Returns:
- All http response headers
- Throws:
java.io.IOException
- If some other I/O error occurs
-
headers
public static java.lang.String headers(java.lang.String url, java.lang.String username, java.lang.String password) throws java.io.IOException
do an HTTP GET on the provided url and return only the HTTP headers- Parameters:
url
- Http urlusername
- Auth usernamepassword
- Auth password- Returns:
- All http response header
- Throws:
java.io.IOException
- If some other I/O error occurs
-
body
public static java.lang.String body(java.lang.String url) throws java.io.IOException
do an HTTP GET on the provided url and return only the HTTP body- Parameters:
url
- Http url- Returns:
- Http response body string value
- Throws:
java.io.IOException
- If some other I/O error occurs
-
body
public static java.lang.String body(java.lang.String url, java.lang.String username, java.lang.String password) throws java.io.IOException
do an HTTP GET on the provided url and return only the HTTP body- Parameters:
url
- Http urlusername
- Auth usernamepassword
- Auth password- Returns:
- Http response body string value
- Throws:
java.io.IOException
- If some other I/O error occurs
-
post
public static java.lang.String post(java.lang.String url, java.lang.String data) throws java.io.IOException
do an HTTP POST to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http post request data- Returns:
- Http response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
post
public static java.lang.String post(java.lang.String url, java.lang.String data, java.util.Map headers) throws java.io.IOException
do an HTTP POST to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http post request dataheaders
- This http post request header- Returns:
- This http post response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
put
public static java.lang.String put(java.lang.String url, java.lang.String data) throws java.io.IOException
do an HTTP PUT to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http put request data- Returns:
- Http response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
put
public static java.lang.String put(java.lang.String url, java.lang.String data, java.util.Map headers) throws java.io.IOException
do an HTTP PUT to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http put request dataheaders
- This http put request header- Returns:
- This http put response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
delete
public static java.lang.String delete(java.lang.String url, java.util.Map headers) throws java.io.IOException
do an HTTP DELETE to the provided url and return the entire response- Parameters:
url
- Http urlheaders
- This http delete request header- Returns:
- Http response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
delete
public static java.lang.String delete(java.lang.String url, java.lang.String data) throws java.io.IOException
do an HTTP DELETE to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http delete request data- Returns:
- Http response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
delete
public static java.lang.String delete(java.lang.String url, java.lang.String data, java.util.Map headers) throws java.io.IOException
do an HTTP DELETE to the provided url and return the entire response- Parameters:
url
- Http urldata
- This http delete request dataheaders
- This http delete request header- Returns:
- This http delete response string
- Throws:
java.io.IOException
- If some other I/O error occurs
-
-