public class HttpRequestUtil extends Object
| Constructor and Description |
|---|
HttpRequestUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
doDelete(URL endpoint,
Map<String,String> headers)
Send
|
static org.wso2.carbon.automation.test.utils.http.client.HttpResponse |
doGet(String endpoint,
Map<String,String> headers) |
static org.wso2.carbon.automation.test.utils.http.client.HttpResponse |
doPost(URL endpoint,
String body) |
static org.wso2.carbon.automation.test.utils.http.client.HttpResponse |
doPost(URL endpoint,
String postBody,
Map<String,String> headers) |
static org.wso2.carbon.automation.test.utils.http.client.HttpResponse |
doPut(URL endpoint,
String putBody,
Map<String,String> headers) |
static int |
sendDeleteRequest(URL endpoint,
String contentType)
Sends an HTTP DELETE request to a url
|
static org.wso2.carbon.automation.test.utils.http.client.HttpResponse |
sendGetRequest(String endpoint,
String requestParameters)
Sends an HTTP GET request to a url
|
static void |
sendPostRequest(Reader data,
URL endpoint,
Writer output)
Reads data from the data reader and posts it to a server via POST request.
|
static void |
sendPostRequest(Reader data,
URL endpoint,
Writer output,
String contentType)
Reads data from the data reader and posts it to a server via POST request.
|
static void |
sendPutRequest(Reader data,
URL endpoint,
Writer output,
String contentType)
Reads data from the data reader and posts it to a server via PUT request.
|
public static org.wso2.carbon.automation.test.utils.http.client.HttpResponse sendGetRequest(String endpoint, String requestParameters) throws IOException
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 yourselfIOException - If an error occurs while sending the GET requestpublic static void sendPostRequest(Reader data, URL endpoint, Writer output) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputException - If an error occurs while POSTingpublic static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost(URL endpoint, String body) throws Exception
Exceptionpublic static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPost(URL endpoint, String postBody, Map<String,String> headers) throws Exception
Exceptionpublic static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doGet(String endpoint, Map<String,String> headers) throws IOException
IOExceptionpublic static void sendPostRequest(Reader data, URL endpoint, Writer output, String contentType) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputcontentType - content type of the messageException - If an error occurs while POSTingpublic static void sendPutRequest(Reader data, URL endpoint, Writer output, String contentType) throws Exception
data - Data to be sentendpoint - The endpoint to which the data has to be POSTedoutput - OutputcontentType - content type of the messageException - If an error occurs while POSTingpublic static org.wso2.carbon.automation.test.utils.http.client.HttpResponse doPut(URL endpoint, String putBody, Map<String,String> headers) throws Exception
endpoint - putBody - headers - Exceptionpublic static int sendDeleteRequest(URL endpoint, String contentType) throws Exception
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")contentType - - content type of the messageIOException - If an error occurs while sending the DELETE requestExceptionpublic static int doDelete(URL endpoint, Map<String,String> headers) throws Exception
endpoint - - The URL of the server. (Example: " http://www.yahoo.com/search")headers - -Exception - - ava.io.IOException If an error occurs while sending the DELETE requestCopyright © 2020 WSO2 Inc. All rights reserved.