Class HarUtils


  • public final class HarUtils
    extends java.lang.Object
    Utility class to parse/create HTTP Archives (HAR) and do conversions between HAR Java classes and HttpMessages (request and response).
    Since:
    2.3.0
    See Also:
    HTTP Archive 1.2, HttpMessage
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CUSTOM_FIELD_PREFIX
      The prefix for custom HAR fields produced by ZAP.
      static java.lang.String MESSAGE_ID_CUSTOM_FIELD
      The name of the custom field that contains the message ID.
      static java.lang.String MESSAGE_NOTE_CUSTOM_FIELD
      The name of the custom field that contains the message note.
      static java.lang.String MESSAGE_TYPE_CUSTOM_FIELD
      The name of the custom field that contains the message type.
    • Field Detail

      • CUSTOM_FIELD_PREFIX

        public static final java.lang.String CUSTOM_FIELD_PREFIX
        The prefix for custom HAR fields produced by ZAP.
        Since:
        2.8.0
        See Also:
        Constant Field Values
      • MESSAGE_ID_CUSTOM_FIELD

        public static final java.lang.String MESSAGE_ID_CUSTOM_FIELD
        The name of the custom field that contains the message ID.
        Since:
        2.8.0
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_CUSTOM_FIELD

        public static final java.lang.String MESSAGE_TYPE_CUSTOM_FIELD
        The name of the custom field that contains the message type.
        Since:
        2.8.0
        See Also:
        Constant Field Values
      • MESSAGE_NOTE_CUSTOM_FIELD

        public static final java.lang.String MESSAGE_NOTE_CUSTOM_FIELD
        The name of the custom field that contains the message note.
        Since:
        2.8.0
        See Also:
        Constant Field Values
    • Method Detail

      • createZapHarLog

        public static edu.umass.cs.benchlab.har.HarLog createZapHarLog()
      • harLogToByteArray

        public static byte[] harLogToByteArray​(edu.umass.cs.benchlab.har.HarLog harLog)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • createHttpMessage

        public static HttpMessage createHttpMessage​(java.lang.String jsonHarRequest)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • createHarRequest

        public static edu.umass.cs.benchlab.har.HarRequest createHarRequest​(java.lang.String jsonHarRequest)
                                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • createHarEntry

        public static edu.umass.cs.benchlab.har.HarEntry createHarEntry​(int historyId,
                                                                        int historyType,
                                                                        HttpMessage httpMessage)
        Creates a HarEntry from the given message with additional custom fields for the history ID/type and note.
        Parameters:
        historyId - the history ID of the HTTP message.
        historyType - the history type of the HTTP message.
        httpMessage - the HTTP message.
        Returns:
        the HarEntry, never null.
        Since:
        2.8.0
        See Also:
        createMessageHarCustomFields(int, int, String)
      • createMessageHarCustomFields

        public static edu.umass.cs.benchlab.har.HarCustomFields createMessageHarCustomFields​(int historyId,
                                                                                             int historyType,
                                                                                             java.lang.String messageNote)
        Creates custom fields for the given data.
        Parameters:
        historyId - the history ID of the HTTP message.
        historyType - the history type of the HTTP message.
        messageNote - the note of the HTTP message.
        Returns:
        the HarCustomFields, never null.
        Since:
        2.8.0
        See Also:
        createHarEntry(int, int, HttpMessage)
      • createHarRequest

        public static edu.umass.cs.benchlab.har.HarRequest createHarRequest​(HttpMessage httpMessage)
      • createHarResponse

        public static edu.umass.cs.benchlab.har.HarResponse createHarResponse​(HttpMessage httpMessage)
      • createHarHeaders

        public static edu.umass.cs.benchlab.har.HarHeaders createHarHeaders​(HttpHeader httpHeader)