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 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: '&param2'=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 sent
      endpoint - The endpoint to which the data has to be POSTed
      output - 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