Class HttpRequestUtil
java.lang.Object
org.wso2.am.integration.test.utils.http.HttpRequestUtil
A utility for handling HTTP requests
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intSendstatic org.wso2.carbon.automation.test.utils.http.client.HttpResponsestatic org.wso2.carbon.automation.test.utils.http.client.HttpResponsestatic org.wso2.carbon.automation.test.utils.http.client.HttpResponsestatic org.wso2.carbon.automation.test.utils.http.client.HttpResponsesendGetRequest(String endpoint, String requestParameters) Sends an HTTP GET request to a urlstatic voidsendPostRequest(Reader data, URL endpoint, Writer output) Reads data from the data reader and posts it to a server via POST request.
-
Constructor Details
-
HttpRequestUtil
public HttpRequestUtil()
-
-
Method Details
-
sendGetRequest
public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse sendGetRequest(String endpoint, String requestParameters) throws IOException Sends an HTTP GET request to a url- Parameters:
endpoint- - The URL of the server. (Example: " http://www.yahoo.com/search")requestParameters- - all the request parameters (Example: "param1=val1invalid input: '¶m2'=val2"). Note: This method will add the question mark (?) to the request - DO NOT add it yourself- Returns:
- - The response from the end point
- Throws:
IOException- If an error occurs while sending the GET request
-
sendPostRequest
Reads data from the data reader and posts it to a server via POST request. data - The data you want to send endpoint - The server's address output - writes the server's response to output- Parameters:
data- Data to be sentendpoint- The endpoint to which the data has to be POSTedoutput- Output- Throws:
Exception- If an error occurs while POSTing
-
doPost
public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost(URL endpoint, String postBody, Map<String, String> headers) throws Exception- Throws:
Exception
-
doGet
public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doGet(String endpoint, Map<String, String> headers) throws IOException- Throws:
IOException
-
doPut
public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPut(URL endpoint, String putBody, Map<String, String> headers) throws Exception- Parameters:
endpoint-putBody-headers-- Returns:
- Throws:
Exception
-
doDelete
Send- Parameters:
endpoint- - The URL of the server. (Example: " http://www.yahoo.com/search")headers- -- Returns:
- - The response code from the endpoint
- Throws:
Exception- - ava.io.IOException If an error occurs while sending the DELETE request
-