Skip to content

Commit

Permalink
Add request and body length fields
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyD97 committed Dec 5, 2022
1 parent a7ed919 commit b775231
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,14 @@ public Object getValueByKey(LogEntryField columnName) {
case REFLECTION_COUNT:
return reflectedParameters.size();
case REQUEST_BODY: // request
if (requestBodyLength == 0) return "";
return new String(getRequestBytes(), getRequestBytes().length - requestBodyLength, requestBodyLength);
return request.bodyAsString();
case REQUEST_BODY_LENGTH:
return request.body().length();
// .substring(request.length - requestBodyLength);
case RESPONSE_BODY: // response
return response.bodyAsString();
case RESPONSE_BODY_LENGTH:
return response.body().length();
case RTT:
return requestResponseDelay;
case REQUEST_HEADERS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum LogEntryField {
BASE64_REQUEST(FieldGroup.REQUEST, String.class, "The entire request encoded in Base64", "AsBase64"),
REQUEST_HEADERS(FieldGroup.REQUEST, String.class, "The request line and associated headers.", "Headers", "Header"),
REQUEST_BODY(FieldGroup.REQUEST, String.class, "The request body.", "Body"),
REQUEST_BODY_LENGTH(FieldGroup.REQUEST, String.class, "The request body's length.", "BodyLength"),
REQUEST_TIME(FieldGroup.REQUEST, Date.class, "Date and time of inital request (as received by L++).", "Time"),
REQUEST_LENGTH(FieldGroup.REQUEST, Integer.class, "The length of the received request.", "Length"),
REQUEST_TOOL(FieldGroup.REQUEST, String.class, "The tool used to initiate the request.", "Tool"), //Alias for proxy.tool,
Expand Down Expand Up @@ -52,6 +53,7 @@ public enum LogEntryField {
BASE64_RESPONSE(FieldGroup.RESPONSE, String.class, "The entire response encoded in Base64", "AsBase64"),
RESPONSE_HEADERS(FieldGroup.RESPONSE, String.class, "The status line and associated headers.", "Headers", "Header"),
RESPONSE_BODY(FieldGroup.RESPONSE, String.class, "The response body.", "Body"),
RESPONSE_BODY_LENGTH(FieldGroup.RESPONSE, String.class, "The response body's length.", "BodyLength"),
RESPONSE_HASH(FieldGroup.RESPONSE, String.class, "SHA1 Hash of the response", "hash", "sha1"),
RESPONSE_TIME(FieldGroup.RESPONSE, Date.class, "Date and time of receiving the response (as received by L++).", "Time"),
RESPONSE_LENGTH(FieldGroup.RESPONSE, Integer.class, "The length of the received response.", "Length"),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/nccgroup/loggerplusplus/util/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ public enum Protocol {HTTP, HTTPS}
.append("{'id':" + REDIRECT_URL + ",'name':'Redirect','defaultVisibleName':'Redirect','visibleName':'Redirect','preferredWidth':250,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(REDIRECT_URL.getDescription()) + "'},")
.append("{'id':" + HAS_SET_COOKIES + ",'name':'HasSetCookies','defaultVisibleName':'Set-Cookie?','visibleName':'Set-Cookie?','preferredWidth':50,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(HAS_SET_COOKIES.getDescription()) + "'},")
.append("{'id':" + REQUEST_BODY + ",'name':'Request','defaultVisibleName':'Request Body','visibleName':'Request Body','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(REQUEST_BODY.getDescription()) + "'},")
.append("{'id':" + REQUEST_BODY_LENGTH + ",'name':'RequestBodyLength','defaultVisibleName':'Request Body Length','visibleName':'Request Body Length','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(REQUEST_BODY_LENGTH.getDescription()) + "'},")
.append("{'id':" + REQUEST_HEADERS + ",'name':'RequestHeaders','defaultVisibleName':'Request Headers','visibleName':'Request Headers','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(REQUEST_HEADERS.getDescription()) + "'},")
.append("{'id':" + RESPONSE_BODY + ",'name':'Response','defaultVisibleName':'Response Body','visibleName':'Response Body','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(RESPONSE_BODY.getDescription()) + "'},")
.append("{'id':" + RESPONSE_BODY_LENGTH + ",'name':'ResponseBodyLength','defaultVisibleName':'Response Body Length','visibleName':'Response Body Length','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(RESPONSE_BODY_LENGTH.getDescription()) + "'},")
.append("{'id':" + RESPONSE_HEADERS + ",'name':'ResponseHeaders','defaultVisibleName':'Response Headers','visibleName':'Response Headers','preferredWidth':150,'readonly':true,'order':" + colOrder++ + ",'visible':false,'description':'" + StringEscapeUtils.escapeJson(RESPONSE_HEADERS.getDescription()) + "'}")
.append("]").toString();

Expand Down

0 comments on commit b775231

Please sign in to comment.