Skip to content

Commit b83b598

Browse files
committed
Remove HttpUtility#patchJson(...)
1 parent c349bad commit b83b598

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

src/main/java/xyz/srnyx/javautilities/HttpUtility.java

+2-31
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.io.InputStreamReader;
1313
import java.net.HttpURLConnection;
1414
import java.net.URI;
15-
import java.util.Optional;
15+
import java.util.*;
1616
import java.util.function.Consumer;
1717
import java.util.function.Function;
1818
import java.util.stream.Collectors;
@@ -22,7 +22,7 @@
2222
* Utility class for making HTTP requests
2323
*/
2424
public class HttpUtility {
25-
public static final boolean DEBUG = false;
25+
public static boolean DEBUG = false;
2626

2727
/**
2828
* 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,
143143
return responseCode;
144144
}
145145

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-
175146
/**
176147
* Sends a DELETE request to the specified URL
177148
*

0 commit comments

Comments
 (0)