Skip to content

Commit

Permalink
fix: http revert
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Oct 2, 2024
1 parent 4ab6d2b commit 0f789a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
32 changes: 14 additions & 18 deletions src/main/java/io/supertokens/httpRequest/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@

package io.supertokens.httpRequest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import io.supertokens.Main;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

import io.supertokens.Main;

public class HttpRequest {

private static final int STATUS_CODE_ERROR_THRESHOLD = 400;
Expand Down Expand Up @@ -67,7 +62,7 @@ private static boolean isJsonValid(String jsonInString) {

@SuppressWarnings("unchecked")
public static <T> T sendGETRequest(Main main, String requestID, String url, Map<String, String> params,
int connectionTimeoutMS, int readTimeoutMS, Integer version)
int connectionTimeoutMS, int readTimeoutMS, Integer version)
throws IOException, HttpResponseException {
StringBuilder paramBuilder = new StringBuilder();

Expand Down Expand Up @@ -129,9 +124,9 @@ public static <T> T sendGETRequest(Main main, String requestID, String url, Map<

@SuppressWarnings("unchecked")
public static <T> T sendGETRequestWithResponseHeaders(Main main, String requestID, String url,
Map<String, String> params,
int connectionTimeoutMS, int readTimeoutMS, Integer version,
Map<String, String> responseHeaders)
Map<String, String> params,
int connectionTimeoutMS, int readTimeoutMS, Integer version,
Map<String, String> responseHeaders)
throws IOException, HttpResponseException {
StringBuilder paramBuilder = new StringBuilder();

Expand Down Expand Up @@ -198,7 +193,7 @@ public static <T> T sendGETRequestWithResponseHeaders(Main main, String requestI
}

private static <T> T sendJsonRequest(Main main, String requestID, String url, JsonElement requestBody,
int connectionTimeoutMS, int readTimeoutMS, Integer version, String method)
int connectionTimeoutMS, int readTimeoutMS, Integer version, String method)
throws IOException, HttpResponseException {
URL obj = getURL(main, requestID, url);
InputStream inputStream = null;
Expand Down Expand Up @@ -262,16 +257,17 @@ public static <T> T sendJsonPOSTRequest(Main main, String requestID, String url,
}

public static <T> T sendJsonPUTRequest(Main main, String requestID, String url, JsonElement requestBody,
int connectionTimeoutMS, int readTimeoutMS, Integer version)
int connectionTimeoutMS, int readTimeoutMS, Integer version)
throws IOException, HttpResponseException {
return sendJsonRequest(main, requestID, url, requestBody, connectionTimeoutMS, readTimeoutMS, version, "PUT");
}

public static <T> T sendJsonDELETERequest(Main main, String requestID, String url, JsonElement requestBody,
int connectionTimeoutMS, int readTimeoutMS, Integer version)
int connectionTimeoutMS, int readTimeoutMS, Integer version)
throws IOException, HttpResponseException {
return sendJsonRequest(main, requestID, url, requestBody, connectionTimeoutMS, readTimeoutMS, version,
"DELETE");
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ public class HttpResponseException extends Exception {
private static final long serialVersionUID = 1L;

public final int statusCode;
public final String rawMessage;

HttpResponseException(int statusCode, String message) {
super("Http error. Status Code: " + statusCode + ". Message: " + message);
this.statusCode = statusCode;
this.rawMessage = message;
}
}
}

0 comments on commit 0f789a3

Please sign in to comment.