com.github.mike10004:har-replay-exec

Library that manages a proxy server that replays traffic from a HAR

License

License

GroupId

GroupId

com.github.mike10004
ArtifactId

ArtifactId

har-replay-exec
Last Version

Last Version

0.32
Release Date

Release Date

Type

Type

jar
Description

Description

Library that manages a proxy server that replays traffic from a HAR

Download har-replay-exec

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mike10004/har-replay-exec/ -->
<dependency>
    <groupId>com.github.mike10004</groupId>
    <artifactId>har-replay-exec</artifactId>
    <version>0.32</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mike10004/har-replay-exec/
implementation 'com.github.mike10004:har-replay-exec:0.32'
// https://jarcasting.com/artifacts/com.github.mike10004/har-replay-exec/
implementation ("com.github.mike10004:har-replay-exec:0.32")
'com.github.mike10004:har-replay-exec:jar:0.32'
<dependency org="com.github.mike10004" name="har-replay-exec" rev="0.32">
  <artifact name="har-replay-exec" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mike10004', module='har-replay-exec', version='0.32')
)
libraryDependencies += "com.github.mike10004" % "har-replay-exec" % "0.32"
[com.github.mike10004/har-replay-exec "0.32"]

Dependencies

compile (10)

Group / Artifact Type Version
com.github.mike10004 : har-replay-vhs jar 0.32
com.github.mike10004 : native-helper jar 10.0.0
com.github.mike10004 : subprocess jar 0.4
net.sf.jopt-simple : jopt-simple jar 5.0.4
org.slf4j : slf4j-simple jar 1.7.25
com.github.mike10004 : crxtool-core jar 0.16
com.browserup : browserup-proxy-core jar 2.0.1
com.opencsv : opencsv jar 4.6
org.apache.tika : tika-core jar 1.22
com.google.code.findbugs : jsr305 jar 3.0.1

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
com.github.mike10004 : har-replay-test-support jar 0.32
com.github.mike10004 : xvfb-manager jar 0.19

Project Modules

There are no modules declared in this project.

Travis build status AppVeyor build status Maven Central

har-replay

Java library and executable for serving recorded HTTP responses from a HAR file. To use it, you provide a HAR file, the library instantiates an HTTP proxy server, and you configure your web browser to use the proxy server. The proxy intercepts each request and responds with the corresponding pre-recorded response from the HAR.

Quick Start

Package

Look in https://repo1.maven.org/maven2/com/github/mike10004/har-replay-dist for the latest .deb file or build the parent project to produce one. Execute

$ sudo dpkg --install /path/to/har-replay-deb  

to install the package. (Replace the filename with the downloaded file or the build product.)

Execute

$ har-replay --port 56789 /path/to/my.har

to start an HTTP proxy on port 56789 serving responses from /path/to/my.har.

Library

Maven dependency:

<dependency>
    <groupId>com.github.mike10004</groupId>
    <artifactId>har-replay-vhs</artifactId>
    <version>0.26</version> <!-- use latest version -->
</dependency>

See Maven badge above for the actual latest version. Example code:

File harFile = new File("my-session.har");
ReplaySessionConfig sessionConfig = ReplaySessionConfig.usingTempDir().build(harFile);
VhsReplayManagerConfig config = VhsReplayManagerConfig.getDefault();
ReplayManager replayManager = new VhsReplayManager(config);
try (ReplaySessionControl sessionControl = replayManager.start(sessionConfig)) {
    URL url = new URL("http://www.example.com/");
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", sessionControl.getListeningPort()));
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);
    try {
        System.out.format("served from HAR: %s %s %s%n", conn.getResponseCode(), conn.getResponseMessage(), url);
        // do something with the connection...
    } finally {
        conn.disconnect();
    }
}

(Imports are from the library and the java.net package.)

The unit tests contain some examples of using the library with an Apache HTTP client and a Selenium Chrome WebDriver client.

FAQ

How do I create a HAR?

See https://toolbox.googleapps.com/apps/har_analyzer/ for instructions on using your web browser to create a HAR file. Another option is to use browsermob-proxy to capture a HAR. The Browsermob method captures some requests the web browser hides from you (because they are trackers or fetch data for browser internals).

Debugging Travis Builds

If the Travis build is failing, you can test locally with Docker by running ./travis-debug.sh. However, the mvn verify command appears to exit early but does not report a nonzero exit code, so it's not clear whether it's actually succeeding or something funky is going on. It should be useful for debugging failures that happen earlier, though. If the failure you see on Travis happens later on in mvn verify, you can follow the Travis Troubleshooting in a local container instructions, which say to execute:

$ docker run --name travis-debug -dit $TRAVIS_IMAGE /sbin/init
$ docker exec -it travis-debug bash -l 

This puts you inside the container, where you can su -l travis, clone the repo, and proceed manually from there.

Versions

Version
0.32
0.31
0.30
0.29
0.28
0.27
0.26
0.25
0.21
0.20
0.19
0.12
0.11