Package de.coho04.githubapi.utilities
Klasse HttpRequestHelper
java.lang.Object
de.coho04.githubapi.utilities.HttpRequestHelper
This class provides helper methods for sending HTTP requests.
-
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic StringextractNextPageUrl(String linkHeader) Extracts the URL of the next page from the Link header.static voidsendDeleteRequest(String url, String githubToken) Sends a DELETE request to the specified URL with the provided GitHub token.static booleansendDeleteRequestWithResponseCode(String url, String githubToken, int responseCode) Sends a DELETE request to the specified URL with the provided GitHub token and checks if the response code matches the expected response code.static StringsendGetRequest(String url, String githubToken) Sends a GET request to the specified URL with the provided GitHub token.static String[]sendGetRequestWithLinkHeader(String url, String githubToken) Sends a GET request to the specified URL with the provided GitHub token and returns the response body and the Link header.static booleansendGetRequestWithResponseCode(String url, String githubToken, int responseCode) Sends a GET request to the specified URL with the provided GitHub token and checks if the response code matches the expected response code.static voidsendPatchRequest(String url, String githubToken, org.json.JSONObject jsonObject) Sends a PATCH request to the specified URL with the provided GitHub token and JSON object.static StringsendPostRequest(String url, String githubToken, org.json.JSONObject jsonObject) Sends a POST request to the specified URL with the provided GitHub token and JSON object.static voidsendPutRequest(String url, String githubToken, org.json.JSONObject jsonObject) Sends a PUT request to the specified URL with the provided GitHub token and JSON object.
-
Felddetails
-
connectionFactory
-
-
Konstruktordetails
-
HttpRequestHelper
public HttpRequestHelper()
-
-
Methodendetails
-
sendPostRequest
public static String sendPostRequest(String url, String githubToken, org.json.JSONObject jsonObject) Sends a POST request to the specified URL with the provided GitHub token and JSON object.- Parameter:
url- the URL to send the request togithubToken- the GitHub tokenjsonObject- the JSON object to send
-
sendGetRequest
Sends a GET request to the specified URL with the provided GitHub token.- Parameter:
url- the URL to send the request togithubToken- the GitHub token- Gibt zurück:
- the response body as a string
-
sendGetRequestWithLinkHeader
Sends a GET request to the specified URL with the provided GitHub token and returns the response body and the Link header.- Parameter:
url- the URL to send the request togithubToken- the GitHub token- Gibt zurück:
- an array containing the response body and the Link header
-
extractNextPageUrl
Extracts the URL of the next page from the Link header.- Parameter:
linkHeader- the Link header- Gibt zurück:
- the URL of the next page
-
sendDeleteRequest
Sends a DELETE request to the specified URL with the provided GitHub token.- Parameter:
url- the URL to send the request togithubToken- the GitHub token
-
sendDeleteRequestWithResponseCode
public static boolean sendDeleteRequestWithResponseCode(String url, String githubToken, int responseCode) Sends a DELETE request to the specified URL with the provided GitHub token and checks if the response code matches the expected response code.- Parameter:
url- the URL to send the request togithubToken- the GitHub tokenresponseCode- the expected response code- Gibt zurück:
- true if the response code matches the expected response code, false otherwise
-
sendGetRequestWithResponseCode
public static boolean sendGetRequestWithResponseCode(String url, String githubToken, int responseCode) Sends a GET request to the specified URL with the provided GitHub token and checks if the response code matches the expected response code.- Parameter:
url- the URL to send the request togithubToken- the GitHub tokenresponseCode- the expected response code- Gibt zurück:
- true if the response code matches the expected response code, false otherwise
-
sendPutRequest
Sends a PUT request to the specified URL with the provided GitHub token and JSON object.- Parameter:
url- the URL to send the request togithubToken- the GitHub tokenjsonObject- the JSON object to send
-
sendPatchRequest
Sends a PATCH request to the specified URL with the provided GitHub token and JSON object.- Parameter:
url- the URL to send the request togithubToken- the GitHub tokenjsonObject- the JSON object to send
-