Class HTTPHelper
java.lang.Object
io.meeds.chat.service.utils.HTTPHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static HttpResponse<String> sendBoundedGetRequest(String url, String token, Duration timeout) Sends a GET request whose whole exchange, the response body included, is bounded bytimeout: an unresponsive Matrix server, or one that stalls in the middle of a body, then fails the call with anHttpTimeoutExceptioninstead of holding the calling thread.protected static HttpResponse<String> sendBoundedPostRequest(String url, String token, String contentAsJson, Duration timeout) Sends a POST request bounded bytimeout, seesendBoundedGetRequest(String, String, Duration).protected static HttpResponse<String> sendBoundedPutRequest(String url, String token, String contentAsJson, Duration timeout) Sends a PUT request bounded bytimeout, seesendBoundedGetRequest(String, String, Duration).protected static HttpResponse<String> sendHttpDeleteRequest(String url, String token, String contentAsJson) protected static HttpResponse<String> sendHttpGetRequest(String url, String token) protected static HttpResponse<String> sendHttpGetRequest(String url, String token, Duration requestTimeout) protected static HttpResponse<String> sendHttpPostRequest(String url, String token, String contentAsJson) protected static HttpResponse<String> sendHttpPostRequest(String url, String token, String mimeType, byte[] fileContent) protected static HttpResponse<String> sendHttpPutRequest(String url, String token, String contentAsJson) static voidsendInvitationToMembers(ArrayList<String> strings, String matrixRoomId)
-
Constructor Details
-
HTTPHelper
public HTTPHelper()
-
-
Method Details
-
sendHttpGetRequest
protected static HttpResponse<String> sendHttpGetRequest(String url, String token) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
sendHttpGetRequest
protected static HttpResponse<String> sendHttpGetRequest(String url, String token, Duration requestTimeout) throws IOException, InterruptedException - Parameters:
requestTimeout- how long to wait for the whole response, headers and body; past it the request is cancelled and the call fails with anHttpTimeoutException- Throws:
IOExceptionInterruptedException
-
sendHttpPostRequest
protected static HttpResponse<String> sendHttpPostRequest(String url, String token, String contentAsJson) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
sendHttpPostRequest
protected static HttpResponse<String> sendHttpPostRequest(String url, String token, String mimeType, byte[] fileContent) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
sendHttpPutRequest
protected static HttpResponse<String> sendHttpPutRequest(String url, String token, String contentAsJson) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
sendHttpDeleteRequest
protected static HttpResponse<String> sendHttpDeleteRequest(String url, String token, String contentAsJson) throws IOException, InterruptedException - Throws:
IOExceptionInterruptedException
-
sendBoundedGetRequest
protected static HttpResponse<String> sendBoundedGetRequest(String url, String token, Duration timeout) throws IOException, InterruptedException Sends a GET request whose whole exchange, the response body included, is bounded bytimeout: an unresponsive Matrix server, or one that stalls in the middle of a body, then fails the call with anHttpTimeoutExceptioninstead of holding the calling thread. SeesendBounded(HttpRequest, Duration).- Parameters:
url- the request urltoken- the bearer access tokentimeout- the request timeout- Returns:
- the response
- Throws:
IOException- when the request fails or times outInterruptedException- when the request is interrupted
-
sendBoundedPostRequest
protected static HttpResponse<String> sendBoundedPostRequest(String url, String token, String contentAsJson, Duration timeout) throws IOException, InterruptedException Sends a POST request bounded bytimeout, seesendBoundedGetRequest(String, String, Duration).- Parameters:
url- the request urltoken- the bearer access token, none when blankcontentAsJson- the JSON bodytimeout- the request timeout- Returns:
- the response
- Throws:
IOException- when the request fails or times outInterruptedException- when the request is interrupted
-
sendBoundedPutRequest
protected static HttpResponse<String> sendBoundedPutRequest(String url, String token, String contentAsJson, Duration timeout) throws IOException, InterruptedException Sends a PUT request bounded bytimeout, seesendBoundedGetRequest(String, String, Duration).- Parameters:
url- the request urltoken- the bearer access tokencontentAsJson- the JSON bodytimeout- the request timeout- Returns:
- the response
- Throws:
IOException- when the request fails or times outInterruptedException- when the request is interrupted
-
sendInvitationToMembers
-