Skip to content

Commit

Permalink
optimization, call analyzeRequest once per click
Browse files Browse the repository at this point in the history
  • Loading branch information
godfuzz3r committed Sep 3, 2023
1 parent ac3ceba commit 7ae7549
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/UnUnicode/UnUnicode.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ public class UnUnicode implements IMessageEditorTab{

private static IExtensionHelpers helpers;

public byte[] getHeaders(byte[] data){
IRequestInfo analyze = helpers.analyzeRequest(data);
int bodyOffset = analyze.getBodyOffset();
byte[] headers = Arrays.copyOfRange(data, 0, bodyOffset);
return headers;
}

public byte[] getBody(byte[] data){
IRequestInfo analyze = helpers.analyzeRequest(data);
int bodyOffset = analyze.getBodyOffset();
byte[] body = Arrays.copyOfRange(data, bodyOffset, data.length);
return body;
}

public byte[] concatHttp(byte[] headers, byte[] content) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(headers);
Expand Down Expand Up @@ -104,8 +90,12 @@ public boolean isEnabled(byte[] content, boolean isRequest)
@Override
public void setMessage(byte[] content, boolean isRequest)
{
byte[] headers = getHeaders(content);
byte[] body = getBody(content);
// split http headers and body
IRequestInfo analyze = helpers.analyzeRequest(content);
int bodyOffset = analyze.getBodyOffset();

byte[] headers = Arrays.copyOfRange(content, 0, bodyOffset);
byte[] body = Arrays.copyOfRange(content, bodyOffset, content.length);

String unescaped = StringEscapeUtils.unescapeJava(new String(body));
if (isJson(unescaped)){
Expand Down

0 comments on commit 7ae7549

Please sign in to comment.