Skip to content

Commit

Permalink
trying to solve problem
Browse files Browse the repository at this point in the history
  • Loading branch information
rgudwin committed Apr 22, 2024
1 parent e594607 commit c77f85f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/br/unicamp/cst/io/rest/HttpCodelet.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public abstract class HttpCodelet extends Codelet {

private static final String application_json = "application/json";
private static final String APPLICATION_JSON = "application/json";

public String sendPOST(String POST_URL, String POST_PARAMS, String method) throws IOException {
URL obj = new URL(POST_URL);
Expand Down Expand Up @@ -97,7 +97,7 @@ public String sendPOST(String POST_URL, HashMap<String, Object> params, String m
String paramsString = prepareParams(params);
return sendPOSTForm(POST_URL, paramsString);
}
else if (method.equals(application_json)){
else if (method.equals(APPLICATION_JSON)){
String payload = IdeaToJSON(params);
return sendPOSTJSON(POST_URL, payload);
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public String sendPOSTForm(String POST_URL, String POST_PARAMS) throws IOExcepti
}

public String sendPOSTJSON(String POST_URL, String payload) throws IOException {
String method = application_json;
String method = APPLICATION_JSON;
URL obj = new URL(POST_URL);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
Expand All @@ -151,7 +151,7 @@ public String sendPOSTJSON(String POST_URL, String payload) throws IOException {
con.setRequestProperty("Content-Type", method);
con.setRequestProperty("mimetype", method);

con.setRequestProperty("Accept", application_json);
con.setRequestProperty("Accept", APPLICATION_JSON);
try(OutputStream os = con.getOutputStream()) {
byte[] input = payload.getBytes(StandardCharsets.UTF_8);
os.write(input);
Expand Down

0 comments on commit c77f85f

Please sign in to comment.