com.github.mike10004:har-replay-vhs

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

License

License

GroupId

GroupId

com.github.mike10004
ArtifactId

ArtifactId

har-replay-vhs
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-vhs

How to add to project

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

Dependencies

compile (5)

Group / Artifact Type Version
com.github.mike10004 : har-replay-core jar 0.32
com.github.mike10004 : virtual-har-server jar 0.32
org.apache.commons : commons-lang3 jar 3.9
org.slf4j : slf4j-api jar 1.7.25
com.google.code.findbugs : jsr305 jar 3.0.1

test (3)

Group / Artifact Type Version
com.github.mike10004 : har-replay-test-support jar 0.32
org.apache.commons : commons-text jar 1.4
com.github.mike10004 : selenium-capture jar 0.56

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.12
0.11