Skip to content

Commit

Permalink
Fixes #196
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyD97 committed Dec 5, 2023
1 parent 02373ad commit 76e7fc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Expand Up @@ -8,6 +8,7 @@
import com.nccgroup.loggerplusplus.util.Globals;
import com.nccgroup.loggerplusplus.util.MoreHelp;
import com.nccgroup.loggerplusplus.util.SwingWorkerWithProgressDialog;
import lombok.extern.log4j.Log4j2;

import javax.swing.*;
import java.awt.event.ActionEvent;
Expand All @@ -16,6 +17,7 @@
import java.lang.reflect.Type;
import java.util.List;

@Log4j2
public class HARExporter extends LogExporter implements ExportPanelProvider, ContextMenuExportProvider {

private final HARExporterControlPanel controlPanel;
Expand Down Expand Up @@ -46,6 +48,8 @@ protected Void doInBackground() throws Exception {
Type logEntryListType = new TypeToken<List<LogEntry>>(){}.getType();
Gson gson = new GsonBuilder().registerTypeAdapter(logEntryListType, new HarSerializer(String.valueOf(Globals.VERSION), "LoggerPlusPlus")).create();
gson.toJson(entries, logEntryListType, fileWriter);
}catch (Exception e){
log.error(e);
}

return null;
Expand Down
Expand Up @@ -148,7 +148,7 @@ public void write(JsonWriter writer, List<LogEntry> logEntries) throws IOExcepti
writer.endArray(); // end response headers array

writer.name("redirectURL").value(String.valueOf(logEntry.getValueByKey(LogEntryField.REDIRECT_URL)));
if (logEntry.getResponseBytes() != null) {
if (logEntry.getResponse() != null) {
writer.name("headersSize").value(logEntry.getResponseBytes().length - logEntry.getResponseBodyLength());
writer.name("bodySize").value(logEntry.getResponseBodyLength());
} else {
Expand Down
Expand Up @@ -379,10 +379,12 @@ private Status processResponse() {
}

public byte[] getRequestBytes() {
if(request == null) return new byte[0];
return this.request.toByteArray().getBytes();
}

public byte[] getResponseBytes() {
if(response == null) return new byte[0];
return response.toByteArray().getBytes();
}

Expand Down

0 comments on commit 76e7fc6

Please sign in to comment.