NAME
Browsermob::Server - Perl client to control the Browsermob Proxy server
VERSION
version 0.16
SYNOPSIS
my $server = Browsermob::Server->new(
path => '/opt/browsermob-proxy-2.0-beta-9/bin/browsermob-proxy'
);
$server->start; # ignore if your server is already started
my $proxy = $server->create_proxy;
my $port = $proxy->port;
$proxy->new_har;
# generate traffic across your port
`curl -x http://localhost:$port http://www.google.com > /dev/null 2>&1`;
print Dumper $proxy->har;
DESCRIPTION
This class provides a way to control the Browsermob Proxy server within Perl. There are only a few public methods for starting and stopping the server. You also have the option of instantiating a server object and pointing it towards an existing BMP server on localhost, and just using it to avoid having to pass the server_port arg when instantiating new proxies.
ATTRIBUTES
path
The path to the browsermob_proxy binary. If you aren't planning to call start
, this is optional.
server_addr
The address of the remote server where the Browsermob Proxy server is running. This defaults to localhost.
port
The port on which the proxy server should run. This is not the port that you should have other clients connect.
METHODS
start
Start a browsermob proxy on port
. Starting the server does not create any proxies.
stop
Stop the forked browsermob-proxy server. This does not work all the time, although the server seems to get GC'd all on its own, even after ignoring a SIGTERM
.
create_proxy
After starting the server, or connecting to an existing one, use create_proxy
to get a proxy that you can use with your tests. No proxies actually exist until you call create_proxy; starting the server does not create a proxy.
my $proxy = $bmp->create_proxy; # returns a Browsermob::Proxy object
my $proxy = $bmp->create_proxy(port => 1337);
get_proxies
Get a list of currently registered proxies.
my $proxy_aref = $bmp->get_proxies->{proxyList};
print scalar @$proxy_aref;
find_open_port
Given a range of valid ports, finds the lowest unused port by searching the proxyList.
my $unused_port = $bmp->find_open_port;
my $proxy = $bmp->create_proxy(port => $unused_port);
SEE ALSO
Please see those modules/websites for more information related to this module.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/gempesaw/Browsermob-Proxy/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Daniel Gempesaw <gempesaw@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Daniel Gempesaw.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.