public class HttpClientRequest extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
HttpClientRequest.CheckedFunction<T,R>
This is a custom functional interface which allows defining a method that throws an IOException.
|
Constructor and Description |
---|
HttpClientRequest() |
Modifier and Type | Method and Description |
---|---|
static HttpResponse |
doGet(String requestUrl)
Sends an HTTP GET request to a url.
|
static HttpResponse |
doGet(String requestUrl,
boolean throwError)
Sends an HTTP GET request to a url.
|
static HttpResponse |
doGet(String requestUrl,
int readTimeout,
HttpClientRequest.CheckedFunction responseBuilder)
Sends an HTTP GET request to a url.
|
static HttpResponse |
doGet(String requestUrl,
Map<String,String> headers)
Sends an HTTP GET request to a url.
|
static HttpResponse |
doHead(String requestUrl)
Sends an HTTP HEAD request to a url.
|
static HttpResponse |
doHead(String requestUrl,
Map<String,String> headers)
Sends an HTTP HEAD request to a url.
|
static HttpResponse |
doMultipartFormData(String requestUrl,
Map<String,String> headers,
Map<String,String> formData)
Sends multipart/form-data requests.
|
static HttpResponse |
doOptions(String requestUrl,
Map<String,String> headers)
Sends an HTTP OPTIONS request to a url.
|
static HttpResponse |
doPost(String endpoint,
String postBody,
Map<String,String> headers)
Send an HTTP POST request to a service.
|
public static HttpResponse doGet(String requestUrl, Map<String,String> headers) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")headers
- - http request header mapIOException
- If an error occurs while sending the GET requestpublic static HttpResponse doGet(String requestUrl, int readTimeout, HttpClientRequest.CheckedFunction responseBuilder) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")readTimeout
- - The read timeout of the requestresponseBuilder
- - Function that allows customizing reading/returning the actual response payloadIOException
- If an error occurs while sending the GET requestpublic static HttpResponse doGet(String requestUrl) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")IOException
- If an error occurs while sending the GET requestpublic static HttpResponse doGet(String requestUrl, boolean throwError) throws IOException
requestUrl
- The URL of the service. (Example: "http://www.yahoo.com/search?params=value")throwError
- Boolean representing whether the error should be thrown instead of printing the stack traceIOException
- If an error occurs while sending the GET request or in case an error response is receivedpublic static HttpResponse doPost(String endpoint, String postBody, Map<String,String> headers) throws IOException
endpoint
- - service endpointpostBody
- - message payloadheaders
- http request headers mapIOException
- If an error occurs while sending the GET requestpublic static HttpResponse doOptions(String requestUrl, Map<String,String> headers) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")headers
- http request headers mapIOException
- If an error occurs while sending the OPTIONS requestpublic static HttpResponse doHead(String requestUrl) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")IOException
- If an error occurs while sending the HEAD requestpublic static HttpResponse doHead(String requestUrl, Map<String,String> headers) throws IOException
requestUrl
- - The URL of the service. (Example: "http://www.yahoo.com/search?params=value")headers
- - http request header mapIOException
- If an error occurs while sending the HEAD requestpublic static HttpResponse doMultipartFormData(String requestUrl, Map<String,String> headers, Map<String,String> formData) throws IOException
requestUrl
- - The URL of the serviceheaders
- - http request header mapformData
- - map of form dataIOException
- If an error occurs while sending the GET requestCopyright © 2018 WSO2. All rights reserved.