Class HarReplayRules

java.lang.Object
com.shaft.gui.browser.internal.HarReplayRules

public final class HarReplayRules extends Object
Builds browser network interception replay rules from a HAR (HTTP Archive) 1.2 file.

Matching is exact: a HAR entry replays only for requests whose HTTP method (case-insensitive) and full request URL (including query string, case-sensitive) are identical to the entry's recorded request.method/request.url. There is no path/query normalization, body matching, or wildcarding, unlike HttpContractRecorder contract replay. Duplicate entries for the same method/URL are replayed in recorded order, one per matching request, mirroring the contract replay cursor behavior.

Entries without a response object, or with a non-positive response.status, are skipped. A response.content.encoding of "base64" is base64-decoded; any other (or missing) encoding is treated as UTF-8 text. The Content-Length and Content-Encoding response headers are dropped when replaying, because HAR response.content.text is always already-decoded per the HAR spec, so passing along the original transfer headers would misrepresent the reconstructed body.

  • Method Details

    • buildRules

      public static List<BrowserNetworkInterceptionRule> buildRules(String harFilePath)
      Builds one mock replay rule from every response-bearing entry in a HAR file.
      Parameters:
      harFilePath - path to a HAR 1.2 JSON file
      Returns:
      replay rules that return recorded HAR responses