Class HttpRequestUtil
- java.lang.Object
-
- org.wso2.am.integration.test.utils.http.HttpRequestUtil
-
public class HttpRequestUtil extends Object
A utility for handling HTTP requests
-
-
Constructor Summary
Constructors Constructor Description HttpRequestUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intdoDelete(URL endpoint, Map<String,String> headers)Sendstatic org.wso2.carbon.automation.test.utils.http.client.HttpResponsedoGet(String endpoint, Map<String,String> headers)static org.wso2.carbon.automation.test.utils.http.client.HttpResponsedoPost(URL endpoint, String postBody, Map<String,String> headers)static org.wso2.carbon.automation.test.utils.http.client.HttpResponsedoPut(URL endpoint, String putBody, Map<String,String> headers)static 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.
-
-
-
Method Detail
-
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=val1¶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
public static void sendPostRequest(Reader data, URL endpoint, Writer output) throws Exception
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
public static int doDelete(URL endpoint, Map<String,String> headers) throws Exception
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
-
-