|
12 | 12 | import java.io.InputStreamReader;
|
13 | 13 | import java.net.HttpURLConnection;
|
14 | 14 | import java.net.URI;
|
15 |
| -import java.util.Optional; |
| 15 | +import java.util.*; |
16 | 16 | import java.util.function.Consumer;
|
17 | 17 | import java.util.function.Function;
|
18 | 18 | import java.util.stream.Collectors;
|
|
22 | 22 | * Utility class for making HTTP requests
|
23 | 23 | */
|
24 | 24 | public class HttpUtility {
|
25 |
| - public static final boolean DEBUG = false; |
| 25 | + public static boolean DEBUG = false; |
26 | 26 |
|
27 | 27 | /**
|
28 | 28 | * Sends a GET request to the specified URL and returns the result of the specified function
|
@@ -143,35 +143,6 @@ public static int putJson(@NotNull String userAgent, @NotNull String urlString,
|
143 | 143 | return responseCode;
|
144 | 144 | }
|
145 | 145 |
|
146 |
| - /** |
147 |
| - * Sends a PATCH request to the specified URL with the specified {@link JsonElement JSON data} |
148 |
| - * |
149 |
| - * @param userAgent the user agent to use |
150 |
| - * @param urlString the URL to send the PATCH request to |
151 |
| - * @param data the {@link JsonElement JSON data} to send with the PATCH request |
152 |
| - * @param connectionConsumer the consumer to apply to the {@link HttpURLConnection} |
153 |
| - * |
154 |
| - * @return the response code of the request |
155 |
| - */ |
156 |
| - public static int patchJson(@NotNull String userAgent, @NotNull String urlString, @NotNull JsonElement data, @Nullable Consumer<HttpURLConnection> connectionConsumer) { |
157 |
| - int responseCode = -1; |
158 |
| - HttpURLConnection connection = null; |
159 |
| - try { |
160 |
| - connection = (HttpURLConnection) URI.create(urlString).toURL().openConnection(); |
161 |
| - connection.setRequestMethod("PATCH"); |
162 |
| - connection.setRequestProperty("User-Agent", userAgent); |
163 |
| - connection.setRequestProperty("Content-Type", "application/json"); |
164 |
| - connection.setDoOutput(true); |
165 |
| - if (connectionConsumer != null) connectionConsumer.accept(connection); |
166 |
| - connection.getOutputStream().write(data.toString().getBytes()); |
167 |
| - responseCode = connection.getResponseCode(); |
168 |
| - } catch (final IOException e) { |
169 |
| - if (DEBUG) e.printStackTrace(); |
170 |
| - } |
171 |
| - if (connection != null) connection.disconnect(); |
172 |
| - return responseCode; |
173 |
| - } |
174 |
| - |
175 | 146 | /**
|
176 | 147 | * Sends a DELETE request to the specified URL
|
177 | 148 | *
|
|
0 commit comments