Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
bakennedy committed Nov 16, 2024
1 parent ff992d2 commit e13ca31
Showing 1 changed file with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package com.moesif.servlet.wrappers;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public class BodyHandler {

public static boolean logBody = true;
public static final int MAX_BODY_SIZE = 10; // Move to a common utility class
public static final int MAX_BODY_SIZE = 10; // Move to a common utility class
public static boolean logBody = true;

public static String encodeContent(byte[] content, String encoding) {
try {
return new String(content, encoding != null ? encoding : StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
return "[UNSUPPORTED ENCODING]";
}
public static String encodeContent(byte[] content, String encoding) {
try {
return new String(content, encoding != null ? encoding : StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
return "[UNSUPPORTED ENCODING]";
}
}

// a method that returns a simple java map representing an error message for large body meant to be serialized into json
public static Map<String, String> getLargeBodyError(long contentLength) {
Map<String, String> error = new HashMap<>();
error.put("msg", "request.body.length " + contentLength + " exceeded requestMaxBodySize of " + MAX_BODY_SIZE + " bytes");
return error;
}
// a method that returns a simple java map representing an error message for large body meant to be serialized into json
public static Map<String, String> getLargeBodyError(long contentLength) {
Map<String, String> error = new HashMap<>();
error.put("msg", "request.body.length " + contentLength + " exceeded requestMaxBodySize of " + MAX_BODY_SIZE + " bytes");
return error;
}

}

0 comments on commit e13ca31

Please sign in to comment.