├── browsermobproxy ├── exceptions.py ├── __init__.py ├── webdriver_event_listener.py ├── server.py └── client.py ├── .gitignore ├── docs ├── _build │ ├── html │ │ ├── objects.inv │ │ ├── _static │ │ │ ├── up.png │ │ │ ├── down.png │ │ │ ├── file.png │ │ │ ├── plus.png │ │ │ ├── comment.png │ │ │ ├── minus.png │ │ │ ├── ajax-loader.gif │ │ │ ├── down-pressed.png │ │ │ ├── up-pressed.png │ │ │ ├── comment-bright.png │ │ │ ├── comment-close.png │ │ │ ├── pygments.css │ │ │ ├── default.css │ │ │ ├── sidebar.js │ │ │ ├── doctools.js │ │ │ ├── basic.css │ │ │ ├── underscore.js │ │ │ └── searchtools.js │ │ ├── _sources │ │ │ ├── server.txt │ │ │ ├── client.txt │ │ │ └── index.txt │ │ ├── .buildinfo │ │ ├── searchindex.js │ │ ├── _modules │ │ │ ├── index.html │ │ │ └── browsermobproxy.html │ │ ├── search.html │ │ ├── py-modindex.html │ │ ├── server.html │ │ ├── index.html │ │ ├── genindex.html │ │ └── client.html │ └── doctrees │ │ ├── client.doctree │ │ ├── index.doctree │ │ ├── server.doctree │ │ └── environment.pickle ├── server.rst ├── client.rst ├── index.rst ├── make.bat ├── Makefile └── conf.py ├── start-servers.sh ├── .travis.yml ├── setup.py ├── bootstrap.sh ├── CONTRIBUTING.md ├── test ├── test_remote.py ├── test_webdriver.py └── test_client.py ├── readme.md └── History.md /browsermobproxy/exceptions.py: -------------------------------------------------------------------------------- 1 | class ProxyServerError(Exception): 2 | pass 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.pyc 4 | dist/ 5 | build/ 6 | *.egg-info/ 7 | .cache/ 8 | bmp.log 9 | .idea/ 10 | -------------------------------------------------------------------------------- /docs/_build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/objects.inv -------------------------------------------------------------------------------- /docs/_build/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/up.png -------------------------------------------------------------------------------- /docs/_build/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/down.png -------------------------------------------------------------------------------- /docs/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/file.png -------------------------------------------------------------------------------- /docs/_build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/plus.png -------------------------------------------------------------------------------- /docs/_build/doctrees/client.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/doctrees/client.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/_build/doctrees/server.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/doctrees/server.doctree -------------------------------------------------------------------------------- /docs/_build/html/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/comment.png -------------------------------------------------------------------------------- /docs/_build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/minus.png -------------------------------------------------------------------------------- /docs/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/_build/html/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/ajax-loader.gif -------------------------------------------------------------------------------- /docs/_build/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/down-pressed.png -------------------------------------------------------------------------------- /docs/_build/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/up-pressed.png -------------------------------------------------------------------------------- /docs/_build/html/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/comment-bright.png -------------------------------------------------------------------------------- /docs/_build/html/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AutomatedTester/browsermob-proxy-py/HEAD/docs/_build/html/_static/comment-close.png -------------------------------------------------------------------------------- /docs/server.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | :mod:`server` Package 5 | --------------------- 6 | .. automodule:: browsermobproxy 7 | .. autoclass:: Server 8 | :members: -------------------------------------------------------------------------------- /docs/client.rst: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | :mod:`client` Package 5 | --------------------- 6 | .. automodule:: browsermobproxy 7 | .. autoclass:: Client 8 | :members: 9 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/server.txt: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | :mod:`server` Package 5 | --------------------- 6 | .. automodule:: browsermobproxy 7 | .. autoclass:: Server 8 | :members: -------------------------------------------------------------------------------- /browsermobproxy/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.5.0' 2 | 3 | from .server import RemoteServer, Server 4 | from .client import Client 5 | 6 | __all__ = ['RemoteServer', 'Server', 'Client', 'browsermobproxy'] 7 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/client.txt: -------------------------------------------------------------------------------- 1 | .. toctree:: 2 | :maxdepth: 2 3 | 4 | :mod:`client` Package 5 | --------------------- 6 | .. automodule:: browsermobproxy 7 | .. autoclass:: Client 8 | :members: 9 | -------------------------------------------------------------------------------- /docs/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 22346719ac3713bfe792fb5638c0a301 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /start-servers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | TOOLS=$(pwd)/tools 3 | cd $TOOLS/browsermob-proxy-2.1.4/bin/ && \ 4 | ./browsermob-proxy --port 9090 & \ 5 | cd $TOOLS && \ 6 | java -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.gecko.driver=geckodriver -jar selenium-server-standalone-3.0.1.jar & -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | jdk: 4 | - oraclejdk8 5 | 6 | addons: 7 | apt: 8 | packages: 9 | - oracle-java8-installer 10 | - oracle-java8-set-default 11 | - google-chrome-stable 12 | 13 | sudo: false 14 | python: 15 | - 2.6 16 | - 2.7 17 | - 3.3 18 | - 3.4 19 | - 3.5 20 | before_script: 21 | - export DISPLAY=:99.0 22 | - sh -e /etc/init.d/xvfb start 23 | - ./bootstrap.sh 24 | - ./start-servers.sh 25 | - sleep 5 26 | install: pip install pytest selenium 27 | script: python setup.py develop && py.test test 28 | sudo: false 29 | dist: trusty 30 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup(name='browsermob-proxy', 4 | version='0.8.0', 5 | description='A library for interacting with the Browsermob Proxy', 6 | author='David Burns', 7 | author_email='david.burns@theautomatedtester.co.uk', 8 | url='http://oss.theautomatedtester.co.uk/browsermob-proxy-py', 9 | classifiers=['Development Status :: 3 - Alpha', 10 | 'Intended Audience :: Developers', 11 | 'License :: OSI Approved :: Apache Software License', 12 | 'Operating System :: POSIX', 13 | 'Operating System :: Microsoft :: Windows', 14 | 'Operating System :: MacOS :: MacOS X', 15 | 'Topic :: Software Development :: Testing', 16 | 'Topic :: Software Development :: Libraries', 17 | 'Programming Language :: Python'], 18 | packages = find_packages(), 19 | install_requires=['requests>=2.9.1'], 20 | ) 21 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [ "$(uname)" == "Darwin" ]; then 3 | echo "We're on a MAC!" 4 | chromeDriver="chromedriver_mac64.zip" 5 | geckoDriverVersion="v0.13.0" 6 | geckoDriver="geckodriver-$geckoDriverVersion-macos.tar.gz" 7 | else 8 | echo "We're not on a MAC!" 9 | chromeDriver="chromedriver_linux64.zip" 10 | geckoDriverVersion="v0.14.0" 11 | geckoDriver="geckodriver-$geckoDriverVersion-linux64.tar.gz" 12 | fi 13 | rm -rf tools 14 | mkdir -p tools && \ 15 | cd tools && \ 16 | wget https://github.com/lightbody/browsermob-proxy/releases/download/browsermob-proxy-2.1.4/browsermob-proxy-2.1.4-bin.zip && \ 17 | unzip -o browsermob-proxy-2.1.4-bin.zip && \ 18 | rm -rf browsermob-proxy*.zip* && \ 19 | wget http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar && \ 20 | wget https://github.com/mozilla/geckodriver/releases/download/${geckoDriverVersion}/${geckoDriver} && \ 21 | tar zxf ${geckoDriver} && \ 22 | rm -rf ${geckoDriver}* && \ 23 | wget https://chromedriver.storage.googleapis.com/2.27/${chromeDriver} && \ 24 | unzip ${chromeDriver} && \ 25 | rm -rf ${chromeDriver}* && \ 26 | cd .. 27 | -------------------------------------------------------------------------------- /browsermobproxy/webdriver_event_listener.py: -------------------------------------------------------------------------------- 1 | from selenium.webdriver.support.abstract_event_listener import AbstractEventListener 2 | 3 | class WebDriverEventListener(AbstractEventListener): 4 | 5 | def __init__(self, client, refs=None): 6 | refs = refs if refs is not None else {} 7 | self.client = client 8 | self.hars = [] 9 | self.refs = refs 10 | 11 | def before_navigate_to(self, url, driver): 12 | if len(self.hars) != 0: 13 | self.hars.append(self.client.har) 14 | self.client.new_har("navigate-to-%s" % url, self.refs) 15 | 16 | def before_navigate_back(self, driver=None): 17 | if driver: 18 | name = "-from-%s" % driver.current_url 19 | else: 20 | name = "navigate-back" 21 | self.client.new_page(name) 22 | 23 | def before_navigate_forward(self, driver=None): 24 | if driver: 25 | name = "-from-%s" % driver.current_url 26 | else: 27 | name = "navigate-forward" 28 | self.client.new_page(name) 29 | 30 | def before_click(self, element, driver): 31 | name = "click-element-%s" % element.id 32 | self.client.new_page(name) 33 | 34 | def before_quit(self, driver): 35 | self.hars.append(self.client.har) 36 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | Firstly, thanks for wanting to contribute back to this project. Below are 4 | guidelines that should hopefully minimise the amount of backwards and forwards 5 | in the review process. 6 | 7 | ## Getting Started 8 | 9 | * Fork the repository on GitHub - well... duh :P 10 | * Create a virtualenv: `virtualenv venv` 11 | * Activate the virtualenv: `. venv/bin/activate` 12 | * Install the package in develop mode: `python setup.py develop` 13 | * Install requirements: `pip install -r requirements.txt` 14 | * Run the tests to check that everything was successful: `py.test tests` 15 | 16 | ## Making Changes 17 | 18 | * Create a topic branch from where you want to base your work. 19 | * This is usually the master branch. 20 | * Only target release branches if you are certain your fix must be on that 21 | branch. 22 | * To quickly create a topic branch based on master; `git checkout -b 23 | /my_contribution master`. Please avoid working directly on the 24 | `master` branch. 25 | * Make commits of logical units. 26 | * Check for unnecessary whitespace with `git diff --check` before committing. 27 | * Make sure you have added the necessary tests for your changes. 28 | * Run _all_ the tests to assure nothing else was accidentally broken. 29 | 30 | ## Submitting Changes 31 | 32 | * Push your changes to a topic branch in your fork of the repository. 33 | * Submit a pull request to the main repository 34 | * After feedback has been given we expect responses within two weeks. After two 35 | weeks will may close the pull request if it isn't showing any activity. 36 | -------------------------------------------------------------------------------- /docs/_build/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | .. BrowserMob Proxy documentation master file, created by 2 | sphinx-quickstart on Fri May 24 12:37:12 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | .. highlightlang:: python 6 | 7 | 8 | 9 | Welcome to BrowserMob Proxy's documentation! 10 | ============================================ 11 | 12 | Python client for the BrowserMob Proxy 2.0 REST API. 13 | 14 | How to install 15 | -------------- 16 | 17 | BrowserMob Proxy is available on PyPI_, so you can install it with ``pip``:: 18 | 19 | $ pip install browsermob-proxy 20 | 21 | Or with `easy_install`:: 22 | 23 | $ easy_install browsermob-proxy 24 | 25 | Or by cloning the repo from GitHub_:: 26 | 27 | $ git clone git://github.com/AutomatedTester/browsermob-proxy-py.git 28 | 29 | Then install it by running:: 30 | 31 | $ python setup.py install 32 | 33 | How to use with selenium-webdriver 34 | ---------------------------------- 35 | 36 | Manually:: 37 | 38 | from browsermobproxy import Server 39 | server = Server("path/to/browsermob-proxy") 40 | server.start() 41 | proxy = server.create_proxy() 42 | 43 | from selenium import webdriver 44 | profile = webdriver.FirefoxProfile() 45 | profile.set_proxy(proxy.selenium_proxy()) 46 | driver = webdriver.Firefox(firefox_profile=profile) 47 | 48 | 49 | proxy.new_har("google") 50 | driver.get("http://www.google.co.uk") 51 | proxy.har # returns a HAR JSON blob 52 | 53 | server.stop() 54 | driver.quit() 55 | 56 | Contents: 57 | 58 | .. toctree:: 59 | :maxdepth: 2 60 | 61 | client.rst 62 | server.rst 63 | 64 | Indices and tables 65 | ================== 66 | 67 | * :ref:`genindex` 68 | * :ref:`modindex` 69 | * :ref:`search` 70 | 71 | .. _GitHub: https://github.com/AutomatedTester/browsermob-proxy-py 72 | .. _PyPI: http://pypi.python.org/pypi/browsermob-proxy 73 | -------------------------------------------------------------------------------- /test/test_remote.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | 3 | from selenium import webdriver 4 | import selenium.webdriver.common.desired_capabilities 5 | import os 6 | import sys 7 | import pytest 8 | 9 | 10 | def setup_module(module): 11 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 12 | 13 | 14 | class TestRemote(object): 15 | def setup_method(self, method): 16 | from browsermobproxy.client import Client 17 | self.client = Client("localhost:9090") 18 | chrome_binary = environ.get("CHROME_BIN", None) 19 | self.desired_caps = selenium.webdriver.common.desired_capabilities.DesiredCapabilities.CHROME 20 | if chrome_binary is not None: 21 | self.desired_caps.update({ 22 | "chromeOptions": { 23 | "binary": chrome_binary, 24 | "args": ['no-sandbox'] 25 | } 26 | }) 27 | self.driver = webdriver.Remote( 28 | desired_capabilities=self.desired_caps, 29 | proxy=self.client) 30 | 31 | def teardown_method(self, method): 32 | self.client.close() 33 | self.driver.quit() 34 | 35 | @pytest.mark.human 36 | def test_set_clear_url_rewrite_rule(self): 37 | targetURL = "https://www.saucelabs.com/versions.js" 38 | assert 200 == self.client.rewrite_url( 39 | "https://www.saucelabs.com/versions.+", "https://www.saucelabs.com/versions.json" 40 | ) 41 | self.driver.get(targetURL) 42 | assert "Sauce Connect" in self.driver.page_source 43 | assert self.client.clear_all_rewrite_url_rules() == 200 44 | self.driver.get(targetURL) 45 | assert "Sauce Connect" not in self.driver.page_source 46 | 47 | @pytest.mark.human 48 | def test_response_interceptor(self): 49 | content = "Response successfully intercepted" 50 | targetURL = "https://saucelabs.com/versions.json?hello" 51 | self.client.response_interceptor( 52 | """if(messageInfo.getOriginalUrl().contains('?hello')){contents.setTextContents("%s");}""" % content 53 | ) 54 | self.driver.get(targetURL) 55 | assert content in self.driver.page_source 56 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | browsermob-proxy-py 2 | =================== 3 | 4 | Python client for the BrowserMob Proxy 2.0 REST API. 5 | 6 | 7 | 8 | How to use with selenium-webdriver 9 | ---------------------------------- 10 | 11 | Manually: 12 | 13 | ``` python 14 | from browsermobproxy import Server 15 | server = Server("path/to/browsermob-proxy") 16 | server.start() 17 | proxy = server.create_proxy() 18 | 19 | from selenium import webdriver 20 | profile = webdriver.FirefoxProfile() 21 | profile.set_proxy(proxy.selenium_proxy()) 22 | driver = webdriver.Firefox(firefox_profile=profile) 23 | 24 | 25 | proxy.new_har("google") 26 | driver.get("http://www.google.co.uk") 27 | proxy.har # returns a HAR JSON blob 28 | 29 | server.stop() 30 | driver.quit() 31 | 32 | ``` 33 | 34 | for Chrome use 35 | 36 | ``` 37 | chrome_options = webdriver.ChromeOptions() 38 | chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy)) 39 | browser = webdriver.Chrome(chrome_options = chrome_options) 40 | ``` 41 | 42 | Running Tests 43 | ------------- 44 | 45 | Install pytest if you don't have it already. 46 | 47 | ```bash 48 | $ pip install pytest 49 | ``` 50 | 51 | Start a browsermob instance. 52 | 53 | ```bash 54 | $ java -jar browsermob.jar --port 9090 55 | ``` 56 | 57 | In a separate window: 58 | 59 | ```bash 60 | $ py.test 61 | ``` 62 | 63 | If you are going to watch the test, the 'human' ones should display an english 64 | muffin instead of the american flag on the 'pick your version' page. Or at 65 | least it does from Canada. 66 | 67 | To run the tests in a CI environment, disable the ones that require human 68 | judgement by adding "-m "not human" test" to the py.test command. 69 | 70 | ```bash 71 | $ py.test -m "not human" test 72 | ``` 73 | 74 | See also 75 | -------- 76 | 77 | * http://proxy.browsermob.com/ 78 | * https://github.com/webmetrics/browsermob-proxy 79 | 80 | Note on Patches/Pull Requests 81 | ----------------------------- 82 | 83 | * Fork the project. 84 | * Make your feature addition or bug fix. 85 | * Add tests for it. This is important so I don't break it in a 86 | future version unintentionally. 87 | * Send me a pull request. Bonus points for topic branches. 88 | 89 | Copyright 90 | --------- 91 | 92 | Copyright 2011 David Burns 93 | 94 | Licensed under the Apache License, Version 2.0 (the "License"); 95 | you may not use this file except in compliance with the License. 96 | You may obtain a copy of the License at 97 | 98 | http://www.apache.org/licenses/LICENSE-2.0 99 | 100 | Unless required by applicable law or agreed to in writing, software 101 | distributed under the License is distributed on an "AS IS" BASIS, 102 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 103 | See the License for the specific language governing permissions and 104 | limitations under the License. 105 | 106 | 107 | -------------------------------------------------------------------------------- /test/test_webdriver.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | 3 | from selenium import webdriver 4 | import selenium.webdriver.common.desired_capabilities 5 | from selenium.webdriver.common.proxy import Proxy 6 | import os 7 | import sys 8 | import copy 9 | import pytest 10 | 11 | def setup_module(module): 12 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 13 | 14 | class TestWebDriver(object): 15 | def setup_method(self, method): 16 | from browsermobproxy.client import Client 17 | self.client = Client("localhost:9090") 18 | self.driver = None 19 | 20 | def teardown_method(self, method): 21 | self.client.close() 22 | if self.driver is not None: 23 | self.driver.quit() 24 | 25 | @pytest.mark.human 26 | def test_i_want_my_by_capability(self): 27 | capabilities = selenium.webdriver.common.desired_capabilities.DesiredCapabilities.CHROME 28 | self.client.add_to_capabilities(capabilities) 29 | # sets self.driver for proper clean up 30 | self._create_webdriver(capabilites=capabilities) 31 | 32 | self._run_url_rewrite_test() 33 | 34 | @pytest.mark.human 35 | def test_i_want_my_by_proxy_object(self): 36 | self._create_webdriver(capabilites=selenium.webdriver.common.desired_capabilities.DesiredCapabilities.CHROME, 37 | proxy=self.client) 38 | 39 | self._run_url_rewrite_test() 40 | 41 | def test_what_things_look_like(self): 42 | bmp_capabilities = copy.deepcopy(selenium.webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX) 43 | self.client.add_to_capabilities(bmp_capabilities) 44 | 45 | proxy_capabilities = copy.deepcopy(selenium.webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX) 46 | proxy_addr = 'localhost:%d' % self.client.port 47 | proxy = Proxy({'httpProxy': proxy_addr,'sslProxy': proxy_addr}) 48 | proxy.add_to_capabilities(proxy_capabilities) 49 | 50 | assert bmp_capabilities == proxy_capabilities 51 | 52 | def _create_webdriver(self, capabilites, proxy=None): 53 | chrome_binary = environ.get("CHROME_BIN", None) 54 | if chrome_binary is not None: 55 | capabilites.update({ 56 | "chromeOptions": { 57 | "binary": chrome_binary, 58 | "args": ['no-sandbox'] 59 | } 60 | }) 61 | if proxy is None: 62 | self.driver = webdriver.Remote(desired_capabilities=capabilites) 63 | else: 64 | self.driver = webdriver.Remote(desired_capabilities=capabilites, proxy=proxy) 65 | 66 | def _run_url_rewrite_test(self): 67 | targetURL = "https://www.saucelabs.com/versions.js" 68 | assert 200 == self.client.rewrite_url( 69 | "https://www.saucelabs.com/versions.+", "https://www.saucelabs.com/versions.json" 70 | ) 71 | self.driver.get(targetURL) 72 | assert "Sauce Connect" in self.driver.page_source 73 | assert self.client.clear_all_rewrite_url_rules() == 200 74 | self.driver.get(targetURL) 75 | assert "Sauce Connect" not in self.driver.page_source 76 | -------------------------------------------------------------------------------- /docs/_build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({envversion:42,terms:{all:[1,2],basic_authent:1,execut:1,whitelist:1,rest:0,bandwidth:1,code:1,comma:1,kbp:1,paramet:[1,2],profil:0,configur:1,param:[],should:2,quiet_period:1,add:1,latenc:1,dict:[],blob:0,har:[0,1],pass:1,match:1,"return":[0,1],string:1,variou:1,get:[0,1,2],read:1,browsermobproxi:[0,1,2],express:1,stop:[0,2],number:1,repo:0,capturecont:1,traffic:1,upstream:1,password:1,ip_address:1,specif:1,list:1,authent:1,server:[],separ:1,retry_count:1,api:[0,1],timeout:1,each:1,through:1,unicod:1,where:1,page:[0,1],www:0,set:[1,2],captur:1,manual:0,idea:1,second:1,remap:1,connect:[1,2],domain:1,arg:2,close:1,process:2,port:[1,2],index:0,statu:1,network:1,item:2,pattern:1,content:[0,1],rewrit:1,retri:1,max:1,"import":0,ref:1,refer:1,shut:1,run:[0,2],webdriver_proxi:1,javascript:1,bodi:1,host:1,dictionari:[1,2],address:1,path:[0,2],wait:[1,2],search:0,quiet:1,against:1,initialis:[1,2],instanc:1,request_interceptor:1,rewrite_url:1,com:0,firefox:0,status_cod:1,modul:0,easy_instal:0,automat:1,down:1,header:1,"boolean":1,empti:2,wait_for_traffic_to_stop:1,regexp:1,regex:1,quit:0,given:1,git:0,from:[0,1],interact:2,json:0,been:1,avail:0,start:[0,2],live:1,basic:1,upstreamkbp:1,until:2,more:2,automatedtest:0,desir:1,option:[1,2],python:0,blacklist:1,hold:2,capturebinarycont:1,cach:1,clear_dns_cach:1,none:1,keyword:1,"default":[1,2],wish:1,setup:0,batch:2,record:1,limit:1,can:[0,2],str:[],remap_host:1,firefoxprofil:0,new_har:[0,1],"int":[],request:1,selenium_proxi:[0,1],capturehead:1,downstreamkbp:1,need:[1,2],replac:1,file:2,pip:0,create_proxi:[0,2],mai:2,downstream:1,want:1,when:1,detail:[1,2],binari:1,valid:1,lookup:1,futur:2,"new":1,you:[0,1,2],respons:1,add_to_cap:1,http:[0,1],allow:2,usernam:1,pypi:0,clone:0,object:[1,2],driver:0,what:1,firefox_profil:0,capabl:1,regular:1,set_proxi:0,associ:1,"class":[1,2],googl:0,handl:1,github:0,response_interceptor:1,url:[1,2],entri:1,clear:1,credenti:1,inform:1,client:[],thi:[1,2],new_pag:1},objtypes:{"0":"py:module","1":"py:method","2":"py:attribute","3":"py:class"},objnames:{"0":["py","module","Python module"],"1":["py","method","Python method"],"2":["py","attribute","Python attribute"],"3":["py","class","Python class"]},filenames:["index","client","server"],titles:["Welcome to BrowserMob Proxy’s documentation!","client Package","server Package"],objects:{"":{browsermobproxy:[2,0,0,"-"]},browsermobproxy:{Client:[1,3,1,""],Server:[2,3,1,""]},"browsermobproxy.Server":{url:[2,2,1,""],start:[2,1,1,""],stop:[2,1,1,""],create_proxy:[2,1,1,""]},"browsermobproxy.Client":{remap_hosts:[1,1,1,""],blacklist:[1,1,1,""],selenium_proxy:[1,1,1,""],response_interceptor:[1,1,1,""],webdriver_proxy:[1,1,1,""],clear_dns_cache:[1,1,1,""],timeouts:[1,1,1,""],whitelist:[1,1,1,""],new_page:[1,1,1,""],basic_authentication:[1,1,1,""],retry:[1,1,1,""],request_interceptor:[1,1,1,""],limits:[1,1,1,""],wait_for_traffic_to_stop:[1,1,1,""],rewrite_url:[1,1,1,""],close:[1,1,1,""],har:[1,2,1,""],add_to_capabilities:[1,1,1,""],headers:[1,1,1,""],new_har:[1,1,1,""]}},titleterms:{welcom:0,packag:[1,2],browsermob:0,selenium:0,webdriv:0,server:2,how:0,client:1,indic:0,tabl:0,instal:0,document:0,proxi:0}}) -------------------------------------------------------------------------------- /docs/_build/html/_modules/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Overview: module code — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 41 | 42 |
43 |
44 |
45 |
46 | 47 |

All modules for which code is available

48 | 50 | 51 |
52 |
53 |
54 |
55 |
56 | 68 | 69 |
70 |
71 |
72 |
73 | 85 | 89 | 90 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. BrowserMob Proxy documentation master file, created by 2 | sphinx-quickstart on Fri May 24 12:37:12 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | .. highlightlang:: python 6 | 7 | 8 | ============================================ 9 | Welcome to BrowserMob Proxy's documentation! 10 | ============================================ 11 | 12 | Python client for the BrowserMob Proxy 2.0 REST API. 13 | 14 | -------------- 15 | How to install 16 | -------------- 17 | 18 | BrowserMob Proxy is available on PyPI_, so you can install it with ``pip``:: 19 | 20 | $ pip install browsermob-proxy 21 | 22 | Or with `easy_install`:: 23 | 24 | $ easy_install browsermob-proxy 25 | 26 | Or by cloning the repo from GitHub_:: 27 | 28 | $ git clone git://github.com/AutomatedTester/browsermob-proxy-py.git 29 | 30 | Then install it by running:: 31 | 32 | $ python setup.py install 33 | 34 | ---------------------------------- 35 | How to use with selenium-webdriver 36 | ---------------------------------- 37 | 38 | Manually:: 39 | 40 | from browsermobproxy import Server 41 | server = Server("path/to/browsermob-proxy") 42 | server.start() 43 | proxy = server.create_proxy() 44 | 45 | from selenium import webdriver 46 | profile = webdriver.FirefoxProfile() 47 | profile.set_proxy(proxy.selenium_proxy()) 48 | driver = webdriver.Firefox(firefox_profile=profile) 49 | 50 | 51 | proxy.new_har("google") 52 | driver.get("http://www.google.co.uk") 53 | proxy.har # returns a HAR JSON blob 54 | 55 | server.stop() 56 | driver.quit() 57 | 58 | ----------------- 59 | How to Contribute 60 | ----------------- 61 | 62 | Getting Started 63 | --------------- 64 | 65 | * Fork the repository on GitHub - well... duh :P 66 | * Create a virtualenv: `virtualenv venv` 67 | * Activate the virtualenv: `. venv/bin/activate` 68 | * Install the package in develop mode: `python setup.py develop` 69 | * Install requirements: `pip install -r requirements.txt` 70 | * Run the tests to check that everything was successful: `py.test tests 71 | 72 | Making Changes 73 | -------------- 74 | 75 | * Create a topic branch from where you want to base your work. 76 | * This is usually the master branch. 77 | * Only target release branches if you are certain your fix must be on that 78 | branch. 79 | * To quickly create a topic branch based on master; `git checkout -b 80 | /my_contribution master`. Please avoid working directly on the 81 | `master` branch. 82 | * Make commits of logical units. 83 | * Check for unnecessary whitespace with `git diff --check` before committing. 84 | * Make sure you have added the necessary tests for your changes. 85 | * Run _all_ the tests to assure nothing else was accidentally broken. 86 | 87 | Submitting Changes 88 | ------------------ 89 | 90 | * Push your changes to a topic branch in your fork of the repository. 91 | * Submit a pull request to the main repository 92 | * After feedback has been given we expect responses within two weeks. After two 93 | weeks will may close the pull request if it isn't showing any activity 94 | 95 | Contents: 96 | 97 | .. toctree:: 98 | :maxdepth: 2 99 | 100 | client.rst 101 | server.rst 102 | 103 | Indices and tables 104 | ================== 105 | 106 | * :ref:`genindex` 107 | * :ref:`modindex` 108 | * :ref:`search` 109 | 110 | .. _GitHub: https://github.com/AutomatedTester/browsermob-proxy-py 111 | .. _PyPI: http://pypi.python.org/pypi/browsermob-proxy 112 | -------------------------------------------------------------------------------- /docs/_build/html/search.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Search — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 49 | 50 |
51 |
52 |
53 |
54 | 55 |

Search

56 |
57 | 58 |

59 | Please activate JavaScript to enable the search 60 | functionality. 61 |

62 |
63 |

64 | From here you can search these documents. Enter your search 65 | words into the box below and click "search". Note that the search 66 | function will automatically search for all of the words. Pages 67 | containing fewer words won't appear in the result list. 68 |

69 |
70 | 71 | 72 | 73 |
74 | 75 |
76 | 77 |
78 | 79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | 100 | 104 | 105 | -------------------------------------------------------------------------------- /docs/_build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 8 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 9 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 10 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 11 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 12 | .highlight .ge { font-style: italic } /* Generic.Emph */ 13 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 14 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 15 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 16 | .highlight .go { color: #333333 } /* Generic.Output */ 17 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 18 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 19 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 20 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 21 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 22 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 23 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 24 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 25 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 26 | .highlight .kt { color: #902000 } /* Keyword.Type */ 27 | .highlight .m { color: #208050 } /* Literal.Number */ 28 | .highlight .s { color: #4070a0 } /* Literal.String */ 29 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 30 | .highlight .nb { color: #007020 } /* Name.Builtin */ 31 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 32 | .highlight .no { color: #60add5 } /* Name.Constant */ 33 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 34 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 35 | .highlight .ne { color: #007020 } /* Name.Exception */ 36 | .highlight .nf { color: #06287e } /* Name.Function */ 37 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 38 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 39 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 40 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 41 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 42 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 43 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 44 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 45 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 46 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 47 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 48 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 49 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 50 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 51 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 52 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 53 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 54 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 55 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 56 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 57 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 58 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 59 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 60 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 61 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 62 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/_build/html/py-modindex.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Python Module Index — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 48 | 49 |
50 |
51 |
52 |
53 | 54 | 55 |

Python Module Index

56 | 57 |
58 | b 59 |
60 | 61 | 62 | 63 | 65 | 66 | 67 | 70 |
 
64 | b
68 | browsermobproxy 69 |
71 | 72 | 73 |
74 |
75 |
76 |
77 |
78 | 90 | 91 |
92 |
93 |
94 |
95 | 107 | 111 | 112 | -------------------------------------------------------------------------------- /docs/_build/html/_modules/browsermobproxy.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | browsermobproxy — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 43 | 44 |
45 |
46 |
47 |
48 | 49 |

Source code for browsermobproxy

50 | __version__ = '0.5.0'
51 | 
52 | from server import Server
53 | from client import Client
54 | 
55 | __all__ = ['Server', 'Client', 'browsermobproxy']
56 | 
57 | 58 |
59 |
60 |
61 |
62 |
63 | 75 | 76 |
77 |
78 |
79 |
80 | 93 | 97 | 98 | -------------------------------------------------------------------------------- /docs/_build/html/_static/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | * default.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- default theme. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | tt { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning tt { 241 | background: #efc2c2; 242 | } 243 | 244 | .note tt { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.8.0 / 2017-02-07 3 | ================== 4 | 5 | * Adds rewrite rules clear api. Fixes content type for request/response intercept and adds doc links for writing intercept code. Adds comments clarifying intercept client test coverage. Augments human test for url rewrite and adds clear portion. Adds test for response intercept. Adds bootstrap script to download tools to test with. Refactors human tests so browser session are cleaned up when tests fail and tests run with chromium. Adds server start script for travis. Changes .travis.yml to use provided scripts and also run headless chrome. 6 | * If the JSON doesn't load, it's likely because the user has another server running on the same port. Improve the error message here so can figure out what's going on more easily. 7 | * Inherit from Exception as StandardError was removed in Python 3 8 | * Add ProxyServerError and raise it instead of Exception 9 | * Fix docstring for limits() 10 | * Fix path join issue: log_path_name would be /server.log 11 | * Make default option values more robust 12 | * Add retry sleep and count in options 13 | * Reenabling timeout tests as they have been fixed in B6 of the server 14 | * Removing duplicate method. Fixes #41 15 | * docstrings cleanup 16 | * configurable log file 17 | * added title options for new har and new har page 18 | * replaced mutable default values with None 19 | * Update Requests dependency version 20 | * Updating supported Python versions 21 | * Disabling a test due to BMP Server bug 22 | * Bumping version number of BMP server used in testing 23 | * Add bmp.log to .gitignore 24 | * Add details on how to contribute 25 | * Updating response URL endpoints to use filter 26 | * Ignoring .cache directory 27 | * Change remap_hosts to accept dictionary 28 | * Make sure the process is still running while waiting for the server to start. 29 | * Changed hostmap to be a named argument for compatibility 30 | * Merge remote-tracking branch 'upstream/master' into patch-1 31 | * Add the ability to empty the DNS cache 32 | * Correct function name 33 | * Add the ability to return all active proxy ports from Browsermob 34 | * switch to Travis container setup 35 | * Update to latest browsermob proxy release for testing 36 | * Correct exception typo 37 | * Update remap_hosts test 38 | * Fix whitespace 39 | * Let remap_hosts accept a dictionary 40 | * Upgrading Travis to it's container system 41 | * bumping to 0.7.1 42 | 43 | 0.7.1 / 2015-07-09 44 | ================== 45 | 46 | * Adding option of using existing proxy port. 47 | * Allow use of a remote proxy server. 48 | * improved directions on running tests 49 | * fix broken test (test_new_page_defaults) 50 | 51 | 0.7.0 / 2015-06-05 52 | ================== 53 | 54 | * Updating travis ci to use browsermob proxy 2.0 55 | * Support to use httpsProxy and httpProxy at proxy creation time 56 | * Adding Python 3 support 57 | * add sslProxy to Client.add_to_capabilities with tests 58 | * Correct docstring for `wait_for_traffic_to_stop` 59 | * Removing unused :Args: items 60 | * Updating docstrings 61 | * Correcting args and params for documentation 62 | * updated docstrings for easier formatting on things like RTDs 63 | * updated new_har() docstrings 64 | * updated client documentation 65 | * Added client and server docs 66 | * updating version in docs 67 | 68 | 0.6.0 / 2014-01-21 69 | ================== 70 | 71 | * Added support for parameters in har creation 72 | * Bug fixes for tests that are out of date 73 | * Setup server constructor to look on path for location of browsermob-proxy executable. As well as looking for a file. Also added example code for using browsermob-proxy with chrome 74 | * Fix project name 75 | * adding docs 76 | 77 | 0.5.0 / 2013-05-23 78 | ================== 79 | * Allow proxying of ssl requests with selenium. 80 | * Updating case for proxy type 81 | 82 | 83 | 0.4.0 / 2013-03-06 84 | ================== 85 | 86 | * Allow setting basic authentication 87 | * Adding the ability to remap hosts which is available from BrowserMob Proxy Beta 7 88 | * Merge pull request #6 from lukeis/patch-2 89 | * Update readme.md 90 | * initial commit of event listener to auto do record 91 | * server.create_proxy is a function, should be called :) 92 | * forgot to add the port 93 | 94 | 0.2.0 / 2012-06-18 95 | ================== 96 | 97 | * pep8 --ignore=E501 98 | * DELETE /proxy/:port/ 99 | * /proxy/:port/limits 100 | * /proxy/:port/blacklist 101 | * /proxy/:port/whitelist 102 | * fixing /proxy/:port/har/pageRef 103 | * fixing /proxy/:port/har/pageRef 104 | * fixing passing in a page ref as the name for the page in /proxy/:port/har 105 | * tests around /proxy/:port/har and some cleanup of the implementation 106 | * make /proxy/:port/headers work 107 | * wrapping selenium_proxy with webdriver_proxy since the project is more than just webdriver 108 | * extending the client to play nice with remote webdriver instances 109 | * create_proxy sounds and feels like a method to me, let's make it so 110 | * ensure the self.process exist, to reduce possibilities of AttributeError 111 | * check the path before attempting to start the server 112 | * wait longer than 3 seconds for the server to come up 113 | 114 | 0.1.0 / 2012-03-22 115 | ================== 116 | 117 | * Removed httplib2 in preference for requests 118 | * Added support for setting headers 119 | 120 | 0.0.1 / 2012-01-16 121 | ================== 122 | 123 | * Initial version 124 | -------------------------------------------------------------------------------- /docs/_build/html/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | // global elements used by the functions. 34 | // the 'sidebarbutton' element is defined as global after its 35 | // creation, in the add_sidebar_button function 36 | var bodywrapper = $('.bodywrapper'); 37 | var sidebar = $('.sphinxsidebar'); 38 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 39 | 40 | // for some reason, the document has no sidebar; do not run into errors 41 | if (!sidebar.length) return; 42 | 43 | // original margin-left of the bodywrapper and width of the sidebar 44 | // with the sidebar expanded 45 | var bw_margin_expanded = bodywrapper.css('margin-left'); 46 | var ssb_width_expanded = sidebar.width(); 47 | 48 | // margin-left of the bodywrapper and width of the sidebar 49 | // with the sidebar collapsed 50 | var bw_margin_collapsed = '.8em'; 51 | var ssb_width_collapsed = '.8em'; 52 | 53 | // colors used by the current theme 54 | var dark_color = $('.related').css('background-color'); 55 | var light_color = $('.document').css('background-color'); 56 | 57 | function sidebar_is_collapsed() { 58 | return sidebarwrapper.is(':not(:visible)'); 59 | } 60 | 61 | function toggle_sidebar() { 62 | if (sidebar_is_collapsed()) 63 | expand_sidebar(); 64 | else 65 | collapse_sidebar(); 66 | } 67 | 68 | function collapse_sidebar() { 69 | sidebarwrapper.hide(); 70 | sidebar.css('width', ssb_width_collapsed); 71 | bodywrapper.css('margin-left', bw_margin_collapsed); 72 | sidebarbutton.css({ 73 | 'margin-left': '0', 74 | 'height': bodywrapper.height() 75 | }); 76 | sidebarbutton.find('span').text('»'); 77 | sidebarbutton.attr('title', _('Expand sidebar')); 78 | document.cookie = 'sidebar=collapsed'; 79 | } 80 | 81 | function expand_sidebar() { 82 | bodywrapper.css('margin-left', bw_margin_expanded); 83 | sidebar.css('width', ssb_width_expanded); 84 | sidebarwrapper.show(); 85 | sidebarbutton.css({ 86 | 'margin-left': ssb_width_expanded-12, 87 | 'height': bodywrapper.height() 88 | }); 89 | sidebarbutton.find('span').text('«'); 90 | sidebarbutton.attr('title', _('Collapse sidebar')); 91 | document.cookie = 'sidebar=expanded'; 92 | } 93 | 94 | function add_sidebar_button() { 95 | sidebarwrapper.css({ 96 | 'float': 'left', 97 | 'margin-right': '0', 98 | 'width': ssb_width_expanded - 28 99 | }); 100 | // create the button 101 | sidebar.append( 102 | '
«
' 103 | ); 104 | var sidebarbutton = $('#sidebarbutton'); 105 | light_color = sidebarbutton.css('background-color'); 106 | // find the height of the viewport to center the '<<' in the page 107 | var viewport_height; 108 | if (window.innerHeight) 109 | viewport_height = window.innerHeight; 110 | else 111 | viewport_height = $(window).height(); 112 | sidebarbutton.find('span').css({ 113 | 'display': 'block', 114 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 115 | }); 116 | 117 | sidebarbutton.click(toggle_sidebar); 118 | sidebarbutton.attr('title', _('Collapse sidebar')); 119 | sidebarbutton.css({ 120 | 'color': '#FFFFFF', 121 | 'border-left': '1px solid ' + dark_color, 122 | 'font-size': '1.2em', 123 | 'cursor': 'pointer', 124 | 'height': bodywrapper.height(), 125 | 'padding-top': '1px', 126 | 'margin-left': ssb_width_expanded - 12 127 | }); 128 | 129 | sidebarbutton.hover( 130 | function () { 131 | $(this).css('background-color', dark_color); 132 | }, 133 | function () { 134 | $(this).css('background-color', light_color); 135 | } 136 | ); 137 | } 138 | 139 | function set_position_from_cookie() { 140 | if (!document.cookie) 141 | return; 142 | var items = document.cookie.split(';'); 143 | for(var k=0; k` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\BrowserMobProxy.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\BrowserMobProxy.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/BrowserMobProxy.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/BrowserMobProxy.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/BrowserMobProxy" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/BrowserMobProxy" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /docs/_build/html/server.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | server Package — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 45 | 46 |
47 |
48 |
49 |
50 | 51 |
52 |
    53 |
54 |
55 |
56 |

server Package

57 |
58 |
59 | class browsermobproxy.Server(path='browsermob-proxy', options={})
60 |

Initialises a Server object

61 | 62 | 63 | 64 | 65 | 66 | 67 | 72 | 73 | 74 |
Args:
Parameters:
    68 |
  • path – Path to the browsermob proxy batch file
  • 69 |
  • options – Dictionary that can hold the port. More items will be added in the future. This defaults to an empty dictionary
  • 70 |
71 |
75 |
76 |
77 | create_proxy()
78 |

Gets a client class that allow to set all the proxy details that you 79 | may need to.

80 |
81 | 82 |
83 |
84 | start()
85 |

This will start the browsermob proxy and then wait until it can 86 | interact with it

87 |
88 | 89 |
90 |
91 | stop()
92 |

This will stop the process running the proxy

93 |
94 | 95 |
96 |
97 | url
98 |

Gets the url that the proxy is running on. This is not the URL clients 99 | should connect to.

100 |
101 | 102 |
103 | 104 |
105 | 106 | 107 |
108 |
109 |
110 |
111 |
112 |

Previous topic

113 |

client Package

115 |

This Page

116 | 120 | 132 | 133 |
134 |
135 |
136 |
137 | 152 | 156 | 157 | -------------------------------------------------------------------------------- /docs/_build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s == 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node) { 70 | if (node.nodeType == 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { 74 | var span = document.createElement("span"); 75 | span.className = className; 76 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 78 | document.createTextNode(val.substr(pos + text.length)), 79 | node.nextSibling)); 80 | node.nodeValue = val.substr(0, pos); 81 | } 82 | } 83 | else if (!jQuery(node).is("button, select, textarea")) { 84 | jQuery.each(node.childNodes, function() { 85 | highlight(this); 86 | }); 87 | } 88 | } 89 | return this.each(function() { 90 | highlight(this); 91 | }); 92 | }; 93 | 94 | /** 95 | * Small JavaScript module for the documentation. 96 | */ 97 | var Documentation = { 98 | 99 | init : function() { 100 | this.fixFirefoxAnchorBug(); 101 | this.highlightSearchWords(); 102 | this.initIndexTable(); 103 | }, 104 | 105 | /** 106 | * i18n support 107 | */ 108 | TRANSLATIONS : {}, 109 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 110 | LOCALE : 'unknown', 111 | 112 | // gettext and ngettext don't access this so that the functions 113 | // can safely bound to a different name (_ = Documentation.gettext) 114 | gettext : function(string) { 115 | var translated = Documentation.TRANSLATIONS[string]; 116 | if (typeof translated == 'undefined') 117 | return string; 118 | return (typeof translated == 'string') ? translated : translated[0]; 119 | }, 120 | 121 | ngettext : function(singular, plural, n) { 122 | var translated = Documentation.TRANSLATIONS[singular]; 123 | if (typeof translated == 'undefined') 124 | return (n == 1) ? singular : plural; 125 | return translated[Documentation.PLURALEXPR(n)]; 126 | }, 127 | 128 | addTranslations : function(catalog) { 129 | for (var key in catalog.messages) 130 | this.TRANSLATIONS[key] = catalog.messages[key]; 131 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 132 | this.LOCALE = catalog.locale; 133 | }, 134 | 135 | /** 136 | * add context elements like header anchor links 137 | */ 138 | addContextElements : function() { 139 | $('div[id] > :header:first').each(function() { 140 | $('\u00B6'). 141 | attr('href', '#' + this.id). 142 | attr('title', _('Permalink to this headline')). 143 | appendTo(this); 144 | }); 145 | $('dt[id]').each(function() { 146 | $('\u00B6'). 147 | attr('href', '#' + this.id). 148 | attr('title', _('Permalink to this definition')). 149 | appendTo(this); 150 | }); 151 | }, 152 | 153 | /** 154 | * workaround a firefox stupidity 155 | */ 156 | fixFirefoxAnchorBug : function() { 157 | if (document.location.hash && $.browser.mozilla) 158 | window.setTimeout(function() { 159 | document.location.href += ''; 160 | }, 10); 161 | }, 162 | 163 | /** 164 | * highlight the search words provided in the url in the text 165 | */ 166 | highlightSearchWords : function() { 167 | var params = $.getQueryParameters(); 168 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 169 | if (terms.length) { 170 | var body = $('div.body'); 171 | if (!body.length) { 172 | body = $('body'); 173 | } 174 | window.setTimeout(function() { 175 | $.each(terms, function() { 176 | body.highlightText(this.toLowerCase(), 'highlighted'); 177 | }); 178 | }, 10); 179 | $('') 181 | .appendTo($('#searchbox')); 182 | } 183 | }, 184 | 185 | /** 186 | * init the domain index toggle buttons 187 | */ 188 | initIndexTable : function() { 189 | var togglers = $('img.toggler').click(function() { 190 | var src = $(this).attr('src'); 191 | var idnum = $(this).attr('id').substr(7); 192 | $('tr.cg-' + idnum).toggle(); 193 | if (src.substr(-9) == 'minus.png') 194 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 195 | else 196 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 197 | }).css('display', ''); 198 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 199 | togglers.click(); 200 | } 201 | }, 202 | 203 | /** 204 | * helper function to hide the search marks again 205 | */ 206 | hideSearchWords : function() { 207 | $('#searchbox .highlight-link').fadeOut(300); 208 | $('span.highlighted').removeClass('highlighted'); 209 | }, 210 | 211 | /** 212 | * make the url absolute 213 | */ 214 | makeURL : function(relativeURL) { 215 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 216 | }, 217 | 218 | /** 219 | * get the current relative url 220 | */ 221 | getCurrentURL : function() { 222 | var path = document.location.pathname; 223 | var parts = path.split(/\//); 224 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 225 | if (this == '..') 226 | parts.pop(); 227 | }); 228 | var url = parts.join('/'); 229 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 230 | } 231 | }; 232 | 233 | // quick alias for translations 234 | _ = Documentation.gettext; 235 | 236 | $(document).ready(function() { 237 | Documentation.init(); 238 | }); 239 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # BrowserMob Proxy documentation build configuration file, created by 4 | # sphinx-quickstart on Fri May 24 12:37:12 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | sys.path.insert(0, os.path.abspath('../')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.coverage', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc'] 29 | autoclass_content = 'both' 30 | 31 | # Add any paths that contain templates here, relative to this directory. 32 | templates_path = ['_templates'] 33 | 34 | # The suffix of source filenames. 35 | source_suffix = '.rst' 36 | 37 | # The encoding of source files. 38 | #source_encoding = 'utf-8-sig' 39 | 40 | # The master toctree document. 41 | master_doc = 'index' 42 | 43 | # General information about the project. 44 | project = u'BrowserMob Proxy' 45 | copyright = u'2014, David Burns' 46 | 47 | # The version info for the project you're documenting, acts as replacement for 48 | # |version| and |release|, also used in various other places throughout the 49 | # built documents. 50 | # 51 | # The short X.Y version. 52 | version = '0.6.0' 53 | # The full version, including alpha/beta/rc tags. 54 | release = '0.6.0' 55 | 56 | # The language for content autogenerated by Sphinx. Refer to documentation 57 | # for a list of supported languages. 58 | #language = None 59 | 60 | # There are two options for replacing |today|: either, you set today to some 61 | # non-false value, then it is used: 62 | #today = '' 63 | # Else, today_fmt is used as the format for a strftime call. 64 | #today_fmt = '%B %d, %Y' 65 | 66 | # List of patterns, relative to source directory, that match files and 67 | # directories to ignore when looking for source files. 68 | exclude_patterns = ['_build'] 69 | 70 | # The reST default role (used for this markup: `text`) to use for all documents. 71 | #default_role = None 72 | 73 | # If true, '()' will be appended to :func: etc. cross-reference text. 74 | #add_function_parentheses = True 75 | 76 | # If true, the current module name will be prepended to all description 77 | # unit titles (such as .. function::). 78 | #add_module_names = True 79 | 80 | # If true, sectionauthor and moduleauthor directives will be shown in the 81 | # output. They are ignored by default. 82 | #show_authors = False 83 | 84 | # The name of the Pygments (syntax highlighting) style to use. 85 | pygments_style = 'sphinx' 86 | 87 | # A list of ignored prefixes for module index sorting. 88 | #modindex_common_prefix = [] 89 | 90 | 91 | # -- Options for HTML output --------------------------------------------------- 92 | 93 | # The theme to use for HTML and HTML Help pages. See the documentation for 94 | # a list of builtin themes. 95 | html_theme = 'default' 96 | 97 | # Theme options are theme-specific and customize the look and feel of a theme 98 | # further. For a list of options available for each theme, see the 99 | # documentation. 100 | #html_theme_options = {} 101 | 102 | # Add any paths that contain custom themes here, relative to this directory. 103 | #html_theme_path = [] 104 | 105 | # The name for this set of Sphinx documents. If None, it defaults to 106 | # " v documentation". 107 | #html_title = None 108 | 109 | # A shorter title for the navigation bar. Default is the same as html_title. 110 | #html_short_title = None 111 | 112 | # The name of an image file (relative to this directory) to place at the top 113 | # of the sidebar. 114 | #html_logo = None 115 | 116 | # The name of an image file (within the static path) to use as favicon of the 117 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 118 | # pixels large. 119 | #html_favicon = None 120 | 121 | # Add any paths that contain custom static files (such as style sheets) here, 122 | # relative to this directory. They are copied after the builtin static files, 123 | # so a file named "default.css" will overwrite the builtin "default.css". 124 | html_static_path = ['_static'] 125 | 126 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 127 | # using the given strftime format. 128 | #html_last_updated_fmt = '%b %d, %Y' 129 | 130 | # If true, SmartyPants will be used to convert quotes and dashes to 131 | # typographically correct entities. 132 | #html_use_smartypants = True 133 | 134 | # Custom sidebar templates, maps document names to template names. 135 | #html_sidebars = {} 136 | 137 | # Additional templates that should be rendered to pages, maps page names to 138 | # template names. 139 | #html_additional_pages = {} 140 | 141 | # If false, no module index is generated. 142 | #html_domain_indices = True 143 | 144 | # If false, no index is generated. 145 | #html_use_index = True 146 | 147 | # If true, the index is split into individual pages for each letter. 148 | #html_split_index = False 149 | 150 | # If true, links to the reST sources are added to the pages. 151 | #html_show_sourcelink = True 152 | 153 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 154 | #html_show_sphinx = True 155 | 156 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 157 | html_show_copyright = True 158 | 159 | # If true, an OpenSearch description file will be output, and all pages will 160 | # contain a tag referring to it. The value of this option must be the 161 | # base URL from which the finished HTML is served. 162 | #html_use_opensearch = '' 163 | 164 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 165 | #html_file_suffix = None 166 | 167 | # Output file base name for HTML help builder. 168 | htmlhelp_basename = 'BrowserMobProxydoc' 169 | 170 | 171 | # -- Options for LaTeX output -------------------------------------------------- 172 | 173 | latex_elements = { 174 | # The paper size ('letterpaper' or 'a4paper'). 175 | #'papersize': 'letterpaper', 176 | 177 | # The font size ('10pt', '11pt' or '12pt'). 178 | #'pointsize': '10pt', 179 | 180 | # Additional stuff for the LaTeX preamble. 181 | #'preamble': '', 182 | } 183 | 184 | # Grouping the document tree into LaTeX files. List of tuples 185 | # (source start file, target name, title, author, documentclass [howto/manual]). 186 | latex_documents = [ 187 | ('index', 'BrowserMobProxy.tex', u'BrowserMob Proxy Documentation', 188 | u'David Burns', 'manual'), 189 | ] 190 | 191 | # The name of an image file (relative to this directory) to place at the top of 192 | # the title page. 193 | #latex_logo = None 194 | 195 | # For "manual" documents, if this is true, then toplevel headings are parts, 196 | # not chapters. 197 | #latex_use_parts = False 198 | 199 | # If true, show page references after internal links. 200 | #latex_show_pagerefs = False 201 | 202 | # If true, show URL addresses after external links. 203 | #latex_show_urls = False 204 | 205 | # Documents to append as an appendix to all manuals. 206 | #latex_appendices = [] 207 | 208 | # If false, no module index is generated. 209 | #latex_domain_indices = True 210 | 211 | 212 | # -- Options for manual page output -------------------------------------------- 213 | 214 | # One entry per manual page. List of tuples 215 | # (source start file, name, description, authors, manual section). 216 | man_pages = [ 217 | ('index', 'browsermobproxy', u'BrowserMob Proxy Documentation', 218 | [u'David Burns'], 1) 219 | ] 220 | 221 | # If true, show URL addresses after external links. 222 | #man_show_urls = False 223 | 224 | 225 | # -- Options for Texinfo output ------------------------------------------------ 226 | 227 | # Grouping the document tree into Texinfo files. List of tuples 228 | # (source start file, target name, title, author, 229 | # dir menu entry, description, category) 230 | texinfo_documents = [ 231 | ('index', 'BrowserMobProxy', u'BrowserMob Proxy Documentation', 232 | u'David Burns', 'BrowserMobProxy', 'One line description of project.', 233 | 'Miscellaneous'), 234 | ] 235 | 236 | # Documents to append as an appendix to all manuals. 237 | #texinfo_appendices = [] 238 | 239 | # If false, no module index is generated. 240 | #texinfo_domain_indices = True 241 | 242 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 243 | #texinfo_show_urls = 'footnote' 244 | -------------------------------------------------------------------------------- /docs/_build/html/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Welcome to BrowserMob Proxy’s documentation! — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 45 | 46 |
47 |
48 |
49 |
50 | 51 |
52 |

Welcome to BrowserMob Proxy’s documentation!

53 |

Python client for the BrowserMob Proxy 2.0 REST API.

54 |
55 |

How to install

56 |

BrowserMob Proxy is available on PyPI, so you can install it with pip:

57 |
$ pip install browsermob-proxy
 58 | 
59 |
60 |

Or with easy_install:

61 |
$ easy_install browsermob-proxy
 62 | 
63 |
64 |

Or by cloning the repo from GitHub:

65 |
$ git clone git://github.com/AutomatedTester/browsermob-proxy-py.git
 66 | 
67 |
68 |

Then install it by running:

69 |
$ python setup.py install
 70 | 
71 |
72 |
73 |
74 |

How to use with selenium-webdriver

75 |

Manually:

76 |
from browsermobproxy import Server
 77 | server = Server("path/to/browsermob-proxy")
 78 | server.start()
 79 | proxy = server.create_proxy()
 80 | 
 81 | from selenium import webdriver
 82 | profile  = webdriver.FirefoxProfile()
 83 | profile.set_proxy(proxy.selenium_proxy())
 84 | driver = webdriver.Firefox(firefox_profile=profile)
 85 | 
 86 | 
 87 | proxy.new_har("google")
 88 | driver.get("http://www.google.co.uk")
 89 | proxy.har # returns a HAR JSON blob
 90 | 
 91 | server.stop()
 92 | driver.quit()
 93 | 
94 |
95 |

Contents:

96 |
97 | 101 |
102 |
103 |
104 |
105 |

Indices and tables

106 | 111 |
112 | 113 | 114 |
115 |
116 |
117 |
118 |
119 |

Table Of Contents

120 | 128 | 129 |

Next topic

130 |

client Package

132 |

This Page

133 | 137 | 149 | 150 |
151 |
152 |
153 |
154 | 169 | 173 | 174 | -------------------------------------------------------------------------------- /test/test_client.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import pytest 3 | import sys 4 | 5 | 6 | def setup_module(module): 7 | sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) 8 | 9 | class TestClient(object): 10 | def setup_method(self, method): 11 | from browsermobproxy.client import Client 12 | self.client = Client("localhost:9090") 13 | 14 | def teardown_method(self, method): 15 | self.client.close() 16 | 17 | def test_we_can_get_list_of_ports(self): 18 | """ 19 | GET /proxy - get a list of ports attached to ProxyServer instances 20 | managed by ProxyManager 21 | """ 22 | ports = self.client.proxy_ports 23 | 24 | assert(len(ports) == 1) 25 | assert(9090 not in ports) 26 | 27 | def test_headers_type(self): 28 | """ 29 | /proxy/:port/headers needs to take a dictionary 30 | """ 31 | with pytest.raises(TypeError): 32 | self.client.headers(['foo']) 33 | 34 | def test_headers_content(self): 35 | """ 36 | /proxy/:port/headers needs to take a dictionary 37 | and returns 200 when its successful 38 | """ 39 | s = self.client.headers({'User-Agent': 'rubber ducks floating in a row'}) 40 | assert(s == 200) 41 | 42 | def test_new_har(self): 43 | """ 44 | /proxy/:port/har 45 | and returns 204 when creating a har with a particular name the first time 46 | and returns 200 and the previous har when creating one with the same name 47 | """ 48 | status_code, har = self.client.new_har() 49 | assert(status_code == 204) 50 | assert(har is None) 51 | status_code, har = self.client.new_har() 52 | assert(status_code == 200) 53 | assert('log' in har) 54 | 55 | def _test_new_har(self): 56 | """ 57 | /proxy/:port/har 58 | and returns 204 when creating a har with a particular name the first time 59 | and returns 200 and the previous har when creating one with the same name 60 | """ 61 | status_code, har = self.client.new_har("elephants") 62 | assert(status_code == 204) 63 | assert(har is None) 64 | status_code, har = self.client.new_har("elephants") 65 | assert(status_code == 200) 66 | assert('elephants' == har["log"]["pages"][0]['id']) 67 | 68 | def test_new_page_defaults(self): 69 | """ 70 | /proxy/:port/pageRef 71 | adds a new page of 'Page N' when no page name is given 72 | """ 73 | self.client.new_har() 74 | self.client.new_page() 75 | har = self.client.har 76 | assert(len(har["log"]["pages"]) == 2) 77 | assert(har["log"]["pages"][1]["id"] == "Page 1") 78 | 79 | def test_new_named_page(self): 80 | """ 81 | /proxy/:port/pageRef 82 | adds a new page of 'buttress' 83 | """ 84 | self.client.new_har() 85 | self.client.new_page('buttress') 86 | har = self.client.har 87 | assert(len(har["log"]["pages"]) == 2) 88 | assert(har["log"]["pages"][1]["id"] == "buttress") 89 | 90 | def test_single_whitelist(self): 91 | """ 92 | /proxy/:port/whitelist 93 | adds a whitelist 94 | """ 95 | status_code = self.client.whitelist("http://www\\.facebook\\.com/.*", 200) 96 | assert(status_code == 200) 97 | 98 | def test_multiple_whitelists(self): 99 | """ 100 | /proxy/:port/whitelist 101 | adds a whitelist 102 | """ 103 | status_code = self.client.whitelist("http://www\\.facebook\\.com/.*,http://cdn\\.twitter\\.com", 200) 104 | assert(status_code == 200) 105 | 106 | def test_blacklist(self): 107 | """ 108 | /proxy/:port/blacklist 109 | adds a blacklist 110 | """ 111 | status_code = self.client.blacklist("http://www\\.facebook\\.com/.*", 200) 112 | assert(status_code == 200) 113 | 114 | def test_basic_authentication(self): 115 | """ 116 | /proxy/:port/auth/basic 117 | adds automatic basic authentication 118 | """ 119 | status_code = self.client.basic_authentication("www.example.com", "myUsername", "myPassword") 120 | assert(status_code == 200) 121 | 122 | def test_limits_invalid_key(self): 123 | """ 124 | /proxy/:port/limits 125 | pre-sending checking that the parameter is correct 126 | """ 127 | with pytest.raises(KeyError): 128 | self.client.limits({"hurray": "explosions"}) 129 | 130 | def test_limits_key_no_value(self): 131 | """ 132 | /proxy/:port/limits 133 | pre-sending checking that a parameter exists 134 | """ 135 | with pytest.raises(KeyError): 136 | self.client.limits({}) 137 | 138 | def test_limits_all_key_values(self): 139 | """ 140 | /proxy/:port/limits 141 | can send all 3 at once based on the proxy implementation 142 | """ 143 | limits = {"upstream_kbps": 320, "downstream_kbps": 560, "latency": 30} 144 | status_code = self.client.limits(limits) 145 | assert(status_code == 200) 146 | 147 | def test_rewrite(self): 148 | """ 149 | /proxy/:port/rewrite 150 | 151 | """ 152 | match = "/foo" 153 | replace = "/bar" 154 | status_code = self.client.rewrite_url(match, replace) 155 | assert(status_code == 200) 156 | 157 | def test_close(self): 158 | """ 159 | /proxy/:port 160 | close the proxy port 161 | """ 162 | status_code = self.client.close() 163 | assert(status_code == 200) 164 | status_code = self.client.close() 165 | assert(status_code == 404) 166 | 167 | def test_response_interceptor_with_parsing_js(self): 168 | """ 169 | /proxy/:port/interceptor/response 170 | This test is only checking very basic syntax rules. The snippet needs to be JAVA/JS 171 | Code only gets validated if the filter/interceptor is used. 172 | """ 173 | js = 'alert("foo")' 174 | status_code = self.client.response_interceptor(js) 175 | assert(status_code == 200) 176 | 177 | def test_response_interceptor_with_invalid_js(self): 178 | """ 179 | /proxy/:port/interceptor/response 180 | This test is only checking very basic syntax rules. The snippet needs to be JAVA/JS 181 | Code only gets validated if the filter/interceptor is used. 182 | """ 183 | js = 'alert("foo"' 184 | status_code = self.client.response_interceptor(js) 185 | assert(status_code == 500) 186 | 187 | def test_request_interceptor_with_parsing_js(self): 188 | """ 189 | /proxy/:port/interceptor/request 190 | This test is only checking very basic syntax rules. The snippet needs to be JAVA/JS 191 | Code only gets validated if the filter/interceptor is used. 192 | """ 193 | js = 'alert("foo")' 194 | status_code = self.client.request_interceptor(js) 195 | assert(status_code == 200) 196 | 197 | def test_request_interceptor_with_invalid_js(self): 198 | """ 199 | /proxy/:port/interceptor/request 200 | This test is only checking very basic syntax rules. The snippet needs to be JAVA/JS 201 | Code only gets validated if the filter/interceptor is used. 202 | """ 203 | js = 'alert("foo"' 204 | status_code = self.client.request_interceptor(js) 205 | assert(status_code == 500) 206 | 207 | def test_timeouts_invalid_timeouts(self): 208 | """ 209 | /proxy/:port/timeout 210 | pre-sending checking that the parameter is correct 211 | """ 212 | with pytest.raises(KeyError): 213 | self.client.timeouts({"hurray": "explosions"}) 214 | 215 | def test_timeouts_key_no_value(self): 216 | """ 217 | /proxy/:port/timeout 218 | pre-sending checking that a parameter exists 219 | """ 220 | with pytest.raises(KeyError): 221 | self.client.timeouts({}) 222 | 223 | def test_timeouts_all_key_values(self): 224 | """ 225 | /proxy/:port/timeout 226 | can send all 3 at once based on the proxy implementation 227 | """ 228 | timeouts = {"request": 2, "read": 2, "connection": 2, "dns": 3} 229 | status_code = self.client.timeouts(timeouts) 230 | assert(status_code == 200) 231 | 232 | def test_remap_hosts(self): 233 | """ 234 | /proxy/:port/hosts 235 | """ 236 | status_code = self.client.remap_hosts("example.com", "1.2.3.4") 237 | assert(status_code == 200) 238 | 239 | def test_remap_hosts_with_hostmap(self): 240 | """ 241 | /proxy/:port/hosts 242 | """ 243 | status_code = self.client.remap_hosts(hostmap={"example.com": "1.2.3.4"}) 244 | assert(status_code == 200) 245 | 246 | def test_wait_for_traffic_to_stop(self): 247 | """ 248 | /proxy/:port/wait 249 | """ 250 | status_code = self.client.wait_for_traffic_to_stop(2000, 10000) 251 | assert(status_code == 200) 252 | 253 | def test_clear_dns_cache(self): 254 | """ 255 | /proxy/:port/dns/cache 256 | """ 257 | status_code = self.client.clear_dns_cache() 258 | assert(status_code == 200) 259 | 260 | def test_rewrite_url(self): 261 | """ 262 | /proxy/:port/rewrite 263 | """ 264 | status_code = self.client.rewrite_url('http://www.facebook\.com', 'http://microsoft.com') 265 | assert(status_code == 200) 266 | 267 | def test_retry(self): 268 | """ 269 | /proxy/:port/retry 270 | """ 271 | status_code = self.client.retry(4) 272 | assert(status_code == 200) 273 | -------------------------------------------------------------------------------- /docs/_build/html/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Index — BrowserMob Proxy 0.6.0 documentation 11 | 12 | 13 | 14 | 15 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 42 | 43 |
44 |
45 |
46 |
47 | 48 | 49 |

Index

50 | 51 |
52 | A 53 | | B 54 | | C 55 | | H 56 | | L 57 | | N 58 | | R 59 | | S 60 | | T 61 | | U 62 | | W 63 | 64 |
65 |

A

66 | 67 | 73 |
68 | 69 |
add_to_capabilities() (browsermobproxy.Client method) 70 |
71 | 72 |
74 | 75 |

B

76 | 77 | 87 | 93 |
78 | 79 |
basic_authentication() (browsermobproxy.Client method) 80 |
81 | 82 | 83 |
blacklist() (browsermobproxy.Client method) 84 |
85 | 86 |
88 | 89 |
browsermobproxy (module), [1] 90 |
91 | 92 |
94 | 95 |

C

96 | 97 | 107 | 117 |
98 | 99 |
clear_dns_cache() (browsermobproxy.Client method) 100 |
101 | 102 | 103 |
Client (class in browsermobproxy) 104 |
105 | 106 |
108 | 109 |
close() (browsermobproxy.Client method) 110 |
111 | 112 | 113 |
create_proxy() (browsermobproxy.Server method) 114 |
115 | 116 |
118 | 119 |

H

120 | 121 | 127 | 133 |
122 | 123 |
har (browsermobproxy.Client attribute) 124 |
125 | 126 |
128 | 129 |
headers() (browsermobproxy.Client method) 130 |
131 | 132 |
134 | 135 |

L

136 | 137 | 143 |
138 | 139 |
limits() (browsermobproxy.Client method) 140 |
141 | 142 |
144 | 145 |

N

146 | 147 | 153 | 159 |
148 | 149 |
new_har() (browsermobproxy.Client method) 150 |
151 | 152 |
154 | 155 |
new_page() (browsermobproxy.Client method) 156 |
157 | 158 |
160 | 161 |

R

162 | 163 | 177 | 187 |
164 | 165 |
remap_hosts() (browsermobproxy.Client method) 166 |
167 | 168 | 169 |
request_interceptor() (browsermobproxy.Client method) 170 |
171 | 172 | 173 |
response_interceptor() (browsermobproxy.Client method) 174 |
175 | 176 |
178 | 179 |
retry() (browsermobproxy.Client method) 180 |
181 | 182 | 183 |
rewrite_url() (browsermobproxy.Client method) 184 |
185 | 186 |
188 | 189 |

S

190 | 191 | 201 | 211 |
192 | 193 |
selenium_proxy() (browsermobproxy.Client method) 194 |
195 | 196 | 197 |
Server (class in browsermobproxy) 198 |
199 | 200 |
202 | 203 |
start() (browsermobproxy.Server method) 204 |
205 | 206 | 207 |
stop() (browsermobproxy.Server method) 208 |
209 | 210 |
212 | 213 |

T

214 | 215 | 221 |
216 | 217 |
timeouts() (browsermobproxy.Client method) 218 |
219 | 220 |
222 | 223 |

U

224 | 225 | 231 |
226 | 227 |
url (browsermobproxy.Server attribute) 228 |
229 | 230 |
232 | 233 |

W

234 | 235 | 245 | 251 |
236 | 237 |
wait_for_traffic_to_stop() (browsermobproxy.Client method) 238 |
239 | 240 | 241 |
webdriver_proxy() (browsermobproxy.Client method) 242 |
243 | 244 |
246 | 247 |
whitelist() (browsermobproxy.Client method) 248 |
249 | 250 |
252 | 253 | 254 | 255 |
256 |
257 |
258 |
259 |
260 | 261 | 262 | 263 | 275 | 276 |
277 |
278 |
279 |
280 | 292 | 296 | 297 | -------------------------------------------------------------------------------- /docs/_build/html/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | /* -- relbar ---------------------------------------------------------------- */ 19 | 20 | div.related { 21 | width: 100%; 22 | font-size: 90%; 23 | } 24 | 25 | div.related h3 { 26 | display: none; 27 | } 28 | 29 | div.related ul { 30 | margin: 0; 31 | padding: 0 0 0 10px; 32 | list-style: none; 33 | } 34 | 35 | div.related li { 36 | display: inline; 37 | } 38 | 39 | div.related li.right { 40 | float: right; 41 | margin-right: 5px; 42 | } 43 | 44 | /* -- sidebar --------------------------------------------------------------- */ 45 | 46 | div.sphinxsidebarwrapper { 47 | padding: 10px 5px 0 10px; 48 | } 49 | 50 | div.sphinxsidebar { 51 | float: left; 52 | width: 230px; 53 | margin-left: -100%; 54 | font-size: 90%; 55 | } 56 | 57 | div.sphinxsidebar ul { 58 | list-style: none; 59 | } 60 | 61 | div.sphinxsidebar ul ul, 62 | div.sphinxsidebar ul.want-points { 63 | margin-left: 20px; 64 | list-style: square; 65 | } 66 | 67 | div.sphinxsidebar ul ul { 68 | margin-top: 0; 69 | margin-bottom: 0; 70 | } 71 | 72 | div.sphinxsidebar form { 73 | margin-top: 10px; 74 | } 75 | 76 | div.sphinxsidebar input { 77 | border: 1px solid #98dbcc; 78 | font-family: sans-serif; 79 | font-size: 1em; 80 | } 81 | 82 | div.sphinxsidebar #searchbox input[type="text"] { 83 | width: 170px; 84 | } 85 | 86 | div.sphinxsidebar #searchbox input[type="submit"] { 87 | width: 30px; 88 | } 89 | 90 | img { 91 | border: 0; 92 | max-width: 100%; 93 | } 94 | 95 | /* -- search page ----------------------------------------------------------- */ 96 | 97 | ul.search { 98 | margin: 10px 0 0 20px; 99 | padding: 0; 100 | } 101 | 102 | ul.search li { 103 | padding: 5px 0 5px 20px; 104 | background-image: url(file.png); 105 | background-repeat: no-repeat; 106 | background-position: 0 7px; 107 | } 108 | 109 | ul.search li a { 110 | font-weight: bold; 111 | } 112 | 113 | ul.search li div.context { 114 | color: #888; 115 | margin: 2px 0 0 30px; 116 | text-align: left; 117 | } 118 | 119 | ul.keywordmatches li.goodmatch a { 120 | font-weight: bold; 121 | } 122 | 123 | /* -- index page ------------------------------------------------------------ */ 124 | 125 | table.contentstable { 126 | width: 90%; 127 | } 128 | 129 | table.contentstable p.biglink { 130 | line-height: 150%; 131 | } 132 | 133 | a.biglink { 134 | font-size: 1.3em; 135 | } 136 | 137 | span.linkdescr { 138 | font-style: italic; 139 | padding-top: 5px; 140 | font-size: 90%; 141 | } 142 | 143 | /* -- general index --------------------------------------------------------- */ 144 | 145 | table.indextable { 146 | width: 100%; 147 | } 148 | 149 | table.indextable td { 150 | text-align: left; 151 | vertical-align: top; 152 | } 153 | 154 | table.indextable dl, table.indextable dd { 155 | margin-top: 0; 156 | margin-bottom: 0; 157 | } 158 | 159 | table.indextable tr.pcap { 160 | height: 10px; 161 | } 162 | 163 | table.indextable tr.cap { 164 | margin-top: 10px; 165 | background-color: #f2f2f2; 166 | } 167 | 168 | img.toggler { 169 | margin-right: 3px; 170 | margin-top: 3px; 171 | cursor: pointer; 172 | } 173 | 174 | div.modindex-jumpbox { 175 | border-top: 1px solid #ddd; 176 | border-bottom: 1px solid #ddd; 177 | margin: 1em 0 1em 0; 178 | padding: 0.4em; 179 | } 180 | 181 | div.genindex-jumpbox { 182 | border-top: 1px solid #ddd; 183 | border-bottom: 1px solid #ddd; 184 | margin: 1em 0 1em 0; 185 | padding: 0.4em; 186 | } 187 | 188 | /* -- general body styles --------------------------------------------------- */ 189 | 190 | a.headerlink { 191 | visibility: hidden; 192 | } 193 | 194 | h1:hover > a.headerlink, 195 | h2:hover > a.headerlink, 196 | h3:hover > a.headerlink, 197 | h4:hover > a.headerlink, 198 | h5:hover > a.headerlink, 199 | h6:hover > a.headerlink, 200 | dt:hover > a.headerlink { 201 | visibility: visible; 202 | } 203 | 204 | div.body p.caption { 205 | text-align: inherit; 206 | } 207 | 208 | div.body td { 209 | text-align: left; 210 | } 211 | 212 | .field-list ul { 213 | padding-left: 1em; 214 | } 215 | 216 | .first { 217 | margin-top: 0 !important; 218 | } 219 | 220 | p.rubric { 221 | margin-top: 30px; 222 | font-weight: bold; 223 | } 224 | 225 | img.align-left, .figure.align-left, object.align-left { 226 | clear: left; 227 | float: left; 228 | margin-right: 1em; 229 | } 230 | 231 | img.align-right, .figure.align-right, object.align-right { 232 | clear: right; 233 | float: right; 234 | margin-left: 1em; 235 | } 236 | 237 | img.align-center, .figure.align-center, object.align-center { 238 | display: block; 239 | margin-left: auto; 240 | margin-right: auto; 241 | } 242 | 243 | .align-left { 244 | text-align: left; 245 | } 246 | 247 | .align-center { 248 | text-align: center; 249 | } 250 | 251 | .align-right { 252 | text-align: right; 253 | } 254 | 255 | /* -- sidebars -------------------------------------------------------------- */ 256 | 257 | div.sidebar { 258 | margin: 0 0 0.5em 1em; 259 | border: 1px solid #ddb; 260 | padding: 7px 7px 0 7px; 261 | background-color: #ffe; 262 | width: 40%; 263 | float: right; 264 | } 265 | 266 | p.sidebar-title { 267 | font-weight: bold; 268 | } 269 | 270 | /* -- topics ---------------------------------------------------------------- */ 271 | 272 | div.topic { 273 | border: 1px solid #ccc; 274 | padding: 7px 7px 0 7px; 275 | margin: 10px 0 10px 0; 276 | } 277 | 278 | p.topic-title { 279 | font-size: 1.1em; 280 | font-weight: bold; 281 | margin-top: 10px; 282 | } 283 | 284 | /* -- admonitions ----------------------------------------------------------- */ 285 | 286 | div.admonition { 287 | margin-top: 10px; 288 | margin-bottom: 10px; 289 | padding: 7px; 290 | } 291 | 292 | div.admonition dt { 293 | font-weight: bold; 294 | } 295 | 296 | div.admonition dl { 297 | margin-bottom: 0; 298 | } 299 | 300 | p.admonition-title { 301 | margin: 0px 10px 5px 0px; 302 | font-weight: bold; 303 | } 304 | 305 | div.body p.centered { 306 | text-align: center; 307 | margin-top: 25px; 308 | } 309 | 310 | /* -- tables ---------------------------------------------------------------- */ 311 | 312 | table.docutils { 313 | border: 0; 314 | border-collapse: collapse; 315 | } 316 | 317 | table.docutils td, table.docutils th { 318 | padding: 1px 8px 1px 5px; 319 | border-top: 0; 320 | border-left: 0; 321 | border-right: 0; 322 | border-bottom: 1px solid #aaa; 323 | } 324 | 325 | table.field-list td, table.field-list th { 326 | border: 0 !important; 327 | } 328 | 329 | table.footnote td, table.footnote th { 330 | border: 0 !important; 331 | } 332 | 333 | th { 334 | text-align: left; 335 | padding-right: 5px; 336 | } 337 | 338 | table.citation { 339 | border-left: solid 1px gray; 340 | margin-left: 1px; 341 | } 342 | 343 | table.citation td { 344 | border-bottom: none; 345 | } 346 | 347 | /* -- other body styles ----------------------------------------------------- */ 348 | 349 | ol.arabic { 350 | list-style: decimal; 351 | } 352 | 353 | ol.loweralpha { 354 | list-style: lower-alpha; 355 | } 356 | 357 | ol.upperalpha { 358 | list-style: upper-alpha; 359 | } 360 | 361 | ol.lowerroman { 362 | list-style: lower-roman; 363 | } 364 | 365 | ol.upperroman { 366 | list-style: upper-roman; 367 | } 368 | 369 | dl { 370 | margin-bottom: 15px; 371 | } 372 | 373 | dd p { 374 | margin-top: 0px; 375 | } 376 | 377 | dd ul, dd table { 378 | margin-bottom: 10px; 379 | } 380 | 381 | dd { 382 | margin-top: 3px; 383 | margin-bottom: 10px; 384 | margin-left: 30px; 385 | } 386 | 387 | dt:target, .highlighted { 388 | background-color: #fbe54e; 389 | } 390 | 391 | dl.glossary dt { 392 | font-weight: bold; 393 | font-size: 1.1em; 394 | } 395 | 396 | .field-list ul { 397 | margin: 0; 398 | padding-left: 1em; 399 | } 400 | 401 | .field-list p { 402 | margin: 0; 403 | } 404 | 405 | .optional { 406 | font-size: 1.3em; 407 | } 408 | 409 | .versionmodified { 410 | font-style: italic; 411 | } 412 | 413 | .system-message { 414 | background-color: #fda; 415 | padding: 5px; 416 | border: 3px solid red; 417 | } 418 | 419 | .footnote:target { 420 | background-color: #ffa; 421 | } 422 | 423 | .line-block { 424 | display: block; 425 | margin-top: 1em; 426 | margin-bottom: 1em; 427 | } 428 | 429 | .line-block .line-block { 430 | margin-top: 0; 431 | margin-bottom: 0; 432 | margin-left: 1.5em; 433 | } 434 | 435 | .guilabel, .menuselection { 436 | font-family: sans-serif; 437 | } 438 | 439 | .accelerator { 440 | text-decoration: underline; 441 | } 442 | 443 | .classifier { 444 | font-style: oblique; 445 | } 446 | 447 | abbr, acronym { 448 | border-bottom: dotted 1px; 449 | cursor: help; 450 | } 451 | 452 | /* -- code displays --------------------------------------------------------- */ 453 | 454 | pre { 455 | overflow: auto; 456 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 457 | } 458 | 459 | td.linenos pre { 460 | padding: 5px 0px; 461 | border: 0; 462 | background-color: transparent; 463 | color: #aaa; 464 | } 465 | 466 | table.highlighttable { 467 | margin-left: 0.5em; 468 | } 469 | 470 | table.highlighttable td { 471 | padding: 0 0.5em 0 0.5em; 472 | } 473 | 474 | tt.descname { 475 | background-color: transparent; 476 | font-weight: bold; 477 | font-size: 1.2em; 478 | } 479 | 480 | tt.descclassname { 481 | background-color: transparent; 482 | } 483 | 484 | tt.xref, a tt { 485 | background-color: transparent; 486 | font-weight: bold; 487 | } 488 | 489 | h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { 490 | background-color: transparent; 491 | } 492 | 493 | .viewcode-link { 494 | float: right; 495 | } 496 | 497 | .viewcode-back { 498 | float: right; 499 | font-family: sans-serif; 500 | } 501 | 502 | div.viewcode-block:target { 503 | margin: -1px -10px; 504 | padding: 0 10px; 505 | } 506 | 507 | /* -- math display ---------------------------------------------------------- */ 508 | 509 | img.math { 510 | vertical-align: middle; 511 | } 512 | 513 | div.body div.math p { 514 | text-align: center; 515 | } 516 | 517 | span.eqno { 518 | float: right; 519 | } 520 | 521 | /* -- printout stylesheet --------------------------------------------------- */ 522 | 523 | @media print { 524 | div.document, 525 | div.documentwrapper, 526 | div.bodywrapper { 527 | margin: 0 !important; 528 | width: 100%; 529 | } 530 | 531 | div.sphinxsidebar, 532 | div.related, 533 | div.footer, 534 | #top-link { 535 | display: none; 536 | } 537 | } -------------------------------------------------------------------------------- /docs/_build/html/_static/underscore.js: -------------------------------------------------------------------------------- 1 | // Underscore.js 1.3.1 2 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. 3 | // Underscore is freely distributable under the MIT license. 4 | // Portions of Underscore are inspired or borrowed from Prototype, 5 | // Oliver Steele's Functional, and John Resig's Micro-Templating. 6 | // For all details and documentation: 7 | // http://documentcloud.github.com/underscore 8 | (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== 9 | c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, 10 | h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= 11 | b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /browsermobproxy/client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | try: 4 | from urllib.parse import urlencode, unquote 5 | except ImportError: 6 | from urllib import urlencode, unquote 7 | import json 8 | 9 | 10 | class Client(object): 11 | def __init__(self, url, params=None, options=None): 12 | """ 13 | Initialises a new Client object 14 | 15 | 16 | :param url: This is where the BrowserMob Proxy lives 17 | :param params: URL query (for example httpProxy and httpsProxy vars) 18 | :param options: Dictionary that can contain the port of an existing 19 | proxy to use (for example 'existing_proxy_port_to_use') 20 | """ 21 | params = params if params is not None else {} 22 | options = options if options is not None else {} 23 | self.host = "http://" + url 24 | if params: 25 | urlparams = "?" + unquote(urlencode(params)) 26 | else: 27 | urlparams = "" 28 | if 'existing_proxy_port_to_use' in options: 29 | self.port = options['existing_proxy_port_to_use'] 30 | else: 31 | resp = requests.post('%s/proxy' % self.host + urlparams) 32 | content = resp.content.decode('utf-8') 33 | try: 34 | jcontent = json.loads(content) 35 | except Exception as e: 36 | raise Exception("Could not read Browsermob-Proxy json\n" 37 | "Another server running on this port?\n%s..." % content[:512]) 38 | self.port = jcontent['port'] 39 | url_parts = self.host.split(":") 40 | self.proxy = url_parts[1][2:] + ":" + str(self.port) 41 | 42 | def close(self): 43 | """ 44 | shuts down the proxy and closes the port 45 | """ 46 | r = requests.delete('%s/proxy/%s' % (self.host, self.port)) 47 | return r.status_code 48 | 49 | # webdriver integration 50 | # ...as a proxy object 51 | def selenium_proxy(self): 52 | """ 53 | Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy 54 | """ 55 | from selenium import webdriver 56 | return webdriver.Proxy({ 57 | "httpProxy": self.proxy, 58 | "sslProxy": self.proxy, 59 | }) 60 | 61 | def webdriver_proxy(self): 62 | """ 63 | Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy 64 | """ 65 | return self.selenium_proxy() 66 | 67 | # ...as a capability 68 | def add_to_capabilities(self, capabilities): 69 | """ 70 | Adds an 'proxy' entry to a desired capabilities dictionary with the 71 | BrowserMob proxy information 72 | 73 | 74 | :param capabilities: The Desired capabilities object from Selenium WebDriver 75 | """ 76 | capabilities['proxy'] = { 77 | 'proxyType': "MANUAL", 78 | 'httpProxy': self.proxy, 79 | 'sslProxy': self.proxy 80 | } 81 | 82 | def add_to_webdriver_capabilities(self, capabilities): 83 | self.add_to_capabilities(capabilities) 84 | 85 | # browsermob proxy api 86 | @property 87 | def proxy_ports(self): 88 | """ 89 | Return a list of proxy ports available 90 | """ 91 | # r should look like {u'proxyList': [{u'port': 8081}]} 92 | r = requests.get('%s/proxy' % self.host).json() 93 | ports = [port['port'] for port in r['proxyList']] 94 | 95 | return ports 96 | 97 | @property 98 | def har(self): 99 | """ 100 | Gets the HAR that has been recorded 101 | """ 102 | r = requests.get('%s/proxy/%s/har' % (self.host, self.port)) 103 | 104 | return r.json() 105 | 106 | def new_har(self, ref=None, options=None, title=None): 107 | """ 108 | This sets a new HAR to be recorded 109 | 110 | :param str ref: A reference for the HAR. Defaults to None 111 | :param dict options: A dictionary that will be passed to BrowserMob 112 | Proxy with specific keywords. Keywords are: 113 | 114 | - captureHeaders: Boolean, capture headers 115 | - captureContent: Boolean, capture content bodies 116 | - captureBinaryContent: Boolean, capture binary content 117 | 118 | :param str title: the title of first har page. Defaults to ref. 119 | """ 120 | options = options if options is not None else {} 121 | payload = {"initialPageRef": ref} if ref is not None else {} 122 | if title is not None: 123 | payload.update({'initialPageTitle': title}) 124 | 125 | if options: 126 | payload.update(options) 127 | 128 | r = requests.put('%s/proxy/%s/har' % (self.host, self.port), payload) 129 | if r.status_code == 200: 130 | return (r.status_code, r.json()) 131 | else: 132 | return (r.status_code, None) 133 | 134 | def new_page(self, ref=None, title=None): 135 | """ 136 | This sets a new page to be recorded 137 | 138 | :param str ref: A reference for the new page. Defaults to None 139 | :param str title: the title of new har page. Defaults to ref. 140 | """ 141 | payload = {"pageRef": ref} if ref is not None else {} 142 | if title is not None: 143 | payload.update({'pageTitle': title}) 144 | r = requests.put('%s/proxy/%s/har/pageRef' % (self.host, self.port), 145 | payload) 146 | return r.status_code 147 | 148 | def blacklist(self, regexp, status_code): 149 | """ 150 | Sets a list of URL patterns to blacklist 151 | 152 | :param str regex: a comma separated list of regular expressions 153 | :param int status_code: the HTTP status code to return for URLs 154 | that do not match the blacklist 155 | """ 156 | r = requests.put('%s/proxy/%s/blacklist' % (self.host, self.port), 157 | {'regex': regexp, 'status': status_code}) 158 | return r.status_code 159 | 160 | def whitelist(self, regexp, status_code): 161 | """ 162 | Sets a list of URL patterns to whitelist 163 | 164 | :param str regex: a comma separated list of regular expressions 165 | :param int status_code: the HTTP status code to return for URLs 166 | that do not match the whitelist 167 | """ 168 | r = requests.put('%s/proxy/%s/whitelist' % (self.host, self.port), 169 | {'regex': regexp, 'status': status_code}) 170 | return r.status_code 171 | 172 | def basic_authentication(self, domain, username, password): 173 | """ 174 | This add automatic basic authentication 175 | 176 | :param str domain: domain to set authentication credentials for 177 | :param str username: valid username to use when authenticating 178 | :param str password: valid password to use when authenticating 179 | """ 180 | r = requests.post(url='%s/proxy/%s/auth/basic/%s' % (self.host, self.port, domain), 181 | data=json.dumps({'username': username, 'password': password}), 182 | headers={'content-type': 'application/json'}) 183 | return r.status_code 184 | 185 | def headers(self, headers): 186 | """ 187 | This sets the headers that will set by the proxy on all requests 188 | 189 | :param dict headers: this is a dictionary of the headers to be set 190 | """ 191 | if not isinstance(headers, dict): 192 | raise TypeError("headers needs to be dictionary") 193 | 194 | r = requests.post(url='%s/proxy/%s/headers' % (self.host, self.port), 195 | data=json.dumps(headers), 196 | headers={'content-type': 'application/json'}) 197 | return r.status_code 198 | 199 | def response_interceptor(self, js): 200 | """ 201 | Executes the java/js code against each response 202 | `HttpRequest request `_, 203 | `HttpMessageContents contents `_, 204 | `HttpMessageInfo messageInfo `_ 205 | are available objects to interact with. 206 | :param str js: the js/java code to execute 207 | """ 208 | r = requests.post(url='%s/proxy/%s/filter/response' % (self.host, self.port), 209 | data=js, 210 | headers={'content-type': 'text/plain'}) 211 | return r.status_code 212 | 213 | def request_interceptor(self, js): 214 | """ 215 | Executes the java/js code against each response 216 | `HttpRequest request `_, 217 | `HttpMessageContents contents `_, 218 | `HttpMessageInfo messageInfo `_ 219 | are available objects to interact with. 220 | :param str js: the js/java code to execute 221 | """ 222 | r = requests.post(url='%s/proxy/%s/filter/request' % (self.host, self.port), 223 | data=js, 224 | headers={'content-type': 'text/plain'}) 225 | return r.status_code 226 | 227 | LIMITS = { 228 | 'upstream_kbps': 'upstreamKbps', 229 | 'downstream_kbps': 'downstreamKbps', 230 | 'latency': 'latency' 231 | } 232 | 233 | def limits(self, options): 234 | """ 235 | Limit the bandwidth through the proxy. 236 | 237 | :param dict options: A dictionary with all the details you want to set. 238 | downstream_kbps - Sets the downstream kbps 239 | upstream_kbps - Sets the upstream kbps 240 | latency - Add the given latency to each HTTP request 241 | """ 242 | params = {} 243 | 244 | for (k, v) in list(options.items()): 245 | if k not in self.LIMITS: 246 | raise KeyError('invalid key: %s' % k) 247 | 248 | params[self.LIMITS[k]] = int(v) 249 | 250 | if len(list(params.items())) == 0: 251 | raise KeyError("You need to specify one of the valid Keys") 252 | 253 | r = requests.put('%s/proxy/%s/limit' % (self.host, self.port), 254 | params) 255 | return r.status_code 256 | 257 | TIMEOUTS = { 258 | 'request': 'requestTimeout', 259 | 'read': 'readTimeout', 260 | 'connection': 'connectionTimeout', 261 | 'dns': 'dnsCacheTimeout' 262 | } 263 | 264 | def timeouts(self, options): 265 | """ 266 | Configure various timeouts in the proxy 267 | 268 | :param dict options: A dictionary with all the details you want to set. 269 | request - request timeout (in seconds) 270 | read - read timeout (in seconds) 271 | connection - connection timeout (in seconds) 272 | dns - dns lookup timeout (in seconds) 273 | """ 274 | params = {} 275 | 276 | for (k, v) in list(options.items()): 277 | if k not in self.TIMEOUTS: 278 | raise KeyError('invalid key: %s' % k) 279 | 280 | params[self.TIMEOUTS[k]] = int(v) 281 | 282 | if len(list(params.items())) == 0: 283 | raise KeyError("You need to specify one of the valid Keys") 284 | 285 | r = requests.put('%s/proxy/%s/timeout' % (self.host, self.port), 286 | params) 287 | return r.status_code 288 | 289 | def remap_hosts(self, address=None, ip_address=None, hostmap=None): 290 | """ 291 | Remap the hosts for a specific URL 292 | 293 | :param str address: url that you wish to remap 294 | :param str ip_address: IP Address that will handle all traffic for 295 | the address passed in 296 | :param **hostmap: Other hosts to be added as keyword arguments 297 | """ 298 | hostmap = hostmap if hostmap is not None else {} 299 | if (address is not None and ip_address is not None): 300 | hostmap[address] = ip_address 301 | 302 | r = requests.post('%s/proxy/%s/hosts' % (self.host, self.port), 303 | json.dumps(hostmap), 304 | headers={'content-type': 'application/json'}) 305 | return r.status_code 306 | 307 | def wait_for_traffic_to_stop(self, quiet_period, timeout): 308 | """ 309 | Waits for the network to be quiet 310 | 311 | :param int quiet_period: number of milliseconds the network needs 312 | to be quiet for 313 | :param int timeout: max number of milliseconds to wait 314 | """ 315 | r = requests.put('%s/proxy/%s/wait' % (self.host, self.port), 316 | {'quietPeriodInMs': quiet_period, 'timeoutInMs': timeout}) 317 | return r.status_code 318 | 319 | def clear_dns_cache(self): 320 | """ 321 | Clears the DNS cache associated with the proxy instance 322 | """ 323 | r = requests.delete('%s/proxy/%s/dns/cache' % (self.host, self.port)) 324 | return r.status_code 325 | 326 | def rewrite_url(self, match, replace): 327 | """ 328 | Rewrites the requested url. 329 | 330 | :param match: a regex to match requests with 331 | :param replace: unicode \ 332 | a string to replace the matches with 333 | """ 334 | params = { 335 | "matchRegex": match, 336 | "replace": replace 337 | } 338 | r = requests.put('%s/proxy/%s/rewrite' % (self.host, self.port), 339 | params) 340 | return r.status_code 341 | 342 | def clear_all_rewrite_url_rules(self): 343 | """ 344 | Clears all URL rewrite rules 345 | :return: status code 346 | """ 347 | 348 | r = requests.delete('%s/proxy/%s/rewrite' % (self.host, self.port)) 349 | return r.status_code 350 | 351 | def retry(self, retry_count): 352 | """ 353 | Retries. No idea what its used for, but its in the API... 354 | 355 | :param int retry_count: the number of retries 356 | """ 357 | r = requests.put('%s/proxy/%s/retry' % (self.host, self.port), 358 | {'retrycount': retry_count}) 359 | return r.status_code 360 | -------------------------------------------------------------------------------- /docs/_build/html/client.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | client Package — BrowserMob Proxy 0.6.0 documentation 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 49 | 50 |
51 |
52 |
53 |
54 | 55 |
56 |
    57 |
58 |
59 |
60 |

client Package

61 |
62 |
63 | class browsermobproxy.Client(url)
64 |

Initialises a new Client object

65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
Parameters:url – This is where the BrowserMob Proxy lives
73 |
74 |
75 | add_to_capabilities(capabilities)
76 |

Adds an ‘proxy’ entry to a desired capabilities dictionary with the 77 | BrowserMob proxy information

78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |
Parameters:capabilities – The Desired capabilities object from Selenium WebDriver
86 |
87 | 88 |
89 |
90 | basic_authentication(domain, username, password)
91 |

This add automatic basic authentication

92 | 93 | 94 | 95 | 96 | 102 | 103 | 104 |
Parameters:
    97 |
  • domain – domain to set authentication credentials for
  • 98 |
  • username – valid username to use when authenticating
  • 99 |
  • password – valid password to use when authenticating
  • 100 |
101 |
105 |
106 | 107 |
108 |
109 | blacklist(regexp, status_code)
110 |

Sets a list of URL patterns to blacklist

111 | 112 | 113 | 114 | 115 | 120 | 121 | 122 |
Parameters:
    116 |
  • regex – a comma separated list of regular expressions
  • 117 |
  • status_code – the HTTP status code to return for URLs that do not match the blacklist
  • 118 |
119 |
123 |
124 | 125 |
126 |
127 | clear_dns_cache()
128 |

Clears the DNS cache associated with the proxy instance

129 |
130 | 131 |
132 |
133 | close()
134 |

shuts down the proxy and closes the port

135 |
136 | 137 |
138 |
139 | har
140 |

Gets the HAR that has been recorded

141 |
142 | 143 |
144 |
145 | headers(headers)
146 |

This sets the headers that will set by the proxy on all requests

147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
Parameters:headers – this is a dictionary of the headers to be set
155 |
156 | 157 |
158 |
159 | limits(options)
160 |

Limit the bandwidth through the proxy.

161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
Parameters:options – A dictionary with all the details you want to set. downstreamKbps - Sets the downstream kbps upstreamKbps - Sets the upstream kbps latency - Add the given latency to each HTTP request
169 |
170 | 171 |
172 |
173 | new_har(ref=None, options={})
174 |

This sets a new HAR to be recorded

175 | 176 | 177 | 178 | 179 | 184 | 185 | 186 |
Parameters:
    180 |
  • ref – A reference for the HAR. Defaults to None
  • 181 |
  • options – A dictionary that will be passed to BrowserMob Proxy with specific keywords. Keywords are: captureHeaders - Boolean, capture headers captureContent - Boolean, capture content bodies captureBinaryContent - Boolean, capture binary content
  • 182 |
183 |
187 |
188 | 189 |
190 |
191 | new_page(ref=None)
192 |

This sets a new page to be recorded

193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 |
Parameters:ref – A reference for the new page. Defaults to None
201 |
202 | 203 |
204 |
205 | remap_hosts(address, ip_address)
206 |

Remap the hosts for a specific URL

207 | 208 | 209 | 210 | 211 | 216 | 217 | 218 |
Parameters:
    212 |
  • address – url that you wish to remap
  • 213 |
  • ip_address – IP Address that will handle all traffic for the address passed in
  • 214 |
215 |
219 |
220 | 221 |
222 |
223 | request_interceptor(js)
224 |

Executes the javascript against each request

225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 |
Parameters:js – the javascript to execute
233 |
234 | 235 |
236 |
237 | response_interceptor(js)
238 |

Executes the javascript against each response

239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 |
Parameters:js – the javascript to execute
247 |
248 | 249 |
250 |
251 | retry(retry_count)
252 |

Retries. No idea what its used for, but its in the API...

253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 |
Parameters:retry_count – the number of retries
261 |
262 | 263 |
264 |
265 | rewrite_url(match, replace)
266 |

Rewrites the requested url.

267 | 268 | 269 | 270 | 271 | 276 | 277 | 278 |
Parameters:
    272 |
  • match – a regex to match requests with
  • 273 |
  • replace – unicode a string to replace the matches with
  • 274 |
275 |
279 |
280 | 281 |
282 |
283 | selenium_proxy()
284 |

Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy

285 |
286 | 287 |
288 |
289 | timeouts(options)
290 |

Configure various timeouts in the proxy

291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 |
Parameters:options – A dictionary with all the details you want to set. request - request timeout (in seconds) read - read timeout (in seconds) connection - connection timeout (in seconds) dns - dns lookup timeout (in seconds)
299 |
300 | 301 |
302 |
303 | wait_for_traffic_to_stop(quiet_period, timeout)
304 |

Waits for the network to be quiet

305 | 306 | 307 | 308 | 309 | 314 | 315 | 316 |
Parameters:
    310 |
  • quiet_period – number of seconds the network needs to be quiet for
  • 311 |
  • timeout – max number of seconds to wait
  • 312 |
313 |
317 |
318 | 319 |
320 |
321 | webdriver_proxy()
322 |

Returns a Selenium WebDriver Proxy class with details of the HTTP Proxy

323 |
324 | 325 |
326 |
327 | whitelist(regexp, status_code)
328 |

Sets a list of URL patterns to whitelist

329 | 330 | 331 | 332 | 333 | 338 | 339 | 340 |
Parameters:
    334 |
  • regex – a comma separated list of regular expressions
  • 335 |
  • status_code – the HTTP status code to return for URLs that do not match the whitelist
  • 336 |
337 |
341 |
342 | 343 |
344 | 345 |
346 | 347 | 348 |
349 |
350 |
351 |
352 |
353 |

Previous topic

354 |

Welcome to BrowserMob Proxy’s documentation!

356 |

Next topic

357 |

server Package

359 |

This Page

360 | 364 | 376 | 377 |
378 |
379 |
380 |
381 | 399 | 403 | 404 | -------------------------------------------------------------------------------- /docs/_build/html/_static/searchtools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * searchtools.js_t 3 | * ~~~~~~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilties for the full-text search. 6 | * 7 | * :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | 13 | /** 14 | * Porter Stemmer 15 | */ 16 | var Stemmer = function() { 17 | 18 | var step2list = { 19 | ational: 'ate', 20 | tional: 'tion', 21 | enci: 'ence', 22 | anci: 'ance', 23 | izer: 'ize', 24 | bli: 'ble', 25 | alli: 'al', 26 | entli: 'ent', 27 | eli: 'e', 28 | ousli: 'ous', 29 | ization: 'ize', 30 | ation: 'ate', 31 | ator: 'ate', 32 | alism: 'al', 33 | iveness: 'ive', 34 | fulness: 'ful', 35 | ousness: 'ous', 36 | aliti: 'al', 37 | iviti: 'ive', 38 | biliti: 'ble', 39 | logi: 'log' 40 | }; 41 | 42 | var step3list = { 43 | icate: 'ic', 44 | ative: '', 45 | alize: 'al', 46 | iciti: 'ic', 47 | ical: 'ic', 48 | ful: '', 49 | ness: '' 50 | }; 51 | 52 | var c = "[^aeiou]"; // consonant 53 | var v = "[aeiouy]"; // vowel 54 | var C = c + "[^aeiouy]*"; // consonant sequence 55 | var V = v + "[aeiou]*"; // vowel sequence 56 | 57 | var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 58 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 59 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 60 | var s_v = "^(" + C + ")?" + v; // vowel in stem 61 | 62 | this.stemWord = function (w) { 63 | var stem; 64 | var suffix; 65 | var firstch; 66 | var origword = w; 67 | 68 | if (w.length < 3) 69 | return w; 70 | 71 | var re; 72 | var re2; 73 | var re3; 74 | var re4; 75 | 76 | firstch = w.substr(0,1); 77 | if (firstch == "y") 78 | w = firstch.toUpperCase() + w.substr(1); 79 | 80 | // Step 1a 81 | re = /^(.+?)(ss|i)es$/; 82 | re2 = /^(.+?)([^s])s$/; 83 | 84 | if (re.test(w)) 85 | w = w.replace(re,"$1$2"); 86 | else if (re2.test(w)) 87 | w = w.replace(re2,"$1$2"); 88 | 89 | // Step 1b 90 | re = /^(.+?)eed$/; 91 | re2 = /^(.+?)(ed|ing)$/; 92 | if (re.test(w)) { 93 | var fp = re.exec(w); 94 | re = new RegExp(mgr0); 95 | if (re.test(fp[1])) { 96 | re = /.$/; 97 | w = w.replace(re,""); 98 | } 99 | } 100 | else if (re2.test(w)) { 101 | var fp = re2.exec(w); 102 | stem = fp[1]; 103 | re2 = new RegExp(s_v); 104 | if (re2.test(stem)) { 105 | w = stem; 106 | re2 = /(at|bl|iz)$/; 107 | re3 = new RegExp("([^aeiouylsz])\\1$"); 108 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 109 | if (re2.test(w)) 110 | w = w + "e"; 111 | else if (re3.test(w)) { 112 | re = /.$/; 113 | w = w.replace(re,""); 114 | } 115 | else if (re4.test(w)) 116 | w = w + "e"; 117 | } 118 | } 119 | 120 | // Step 1c 121 | re = /^(.+?)y$/; 122 | if (re.test(w)) { 123 | var fp = re.exec(w); 124 | stem = fp[1]; 125 | re = new RegExp(s_v); 126 | if (re.test(stem)) 127 | w = stem + "i"; 128 | } 129 | 130 | // Step 2 131 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; 132 | if (re.test(w)) { 133 | var fp = re.exec(w); 134 | stem = fp[1]; 135 | suffix = fp[2]; 136 | re = new RegExp(mgr0); 137 | if (re.test(stem)) 138 | w = stem + step2list[suffix]; 139 | } 140 | 141 | // Step 3 142 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; 143 | if (re.test(w)) { 144 | var fp = re.exec(w); 145 | stem = fp[1]; 146 | suffix = fp[2]; 147 | re = new RegExp(mgr0); 148 | if (re.test(stem)) 149 | w = stem + step3list[suffix]; 150 | } 151 | 152 | // Step 4 153 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; 154 | re2 = /^(.+?)(s|t)(ion)$/; 155 | if (re.test(w)) { 156 | var fp = re.exec(w); 157 | stem = fp[1]; 158 | re = new RegExp(mgr1); 159 | if (re.test(stem)) 160 | w = stem; 161 | } 162 | else if (re2.test(w)) { 163 | var fp = re2.exec(w); 164 | stem = fp[1] + fp[2]; 165 | re2 = new RegExp(mgr1); 166 | if (re2.test(stem)) 167 | w = stem; 168 | } 169 | 170 | // Step 5 171 | re = /^(.+?)e$/; 172 | if (re.test(w)) { 173 | var fp = re.exec(w); 174 | stem = fp[1]; 175 | re = new RegExp(mgr1); 176 | re2 = new RegExp(meq1); 177 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 178 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) 179 | w = stem; 180 | } 181 | re = /ll$/; 182 | re2 = new RegExp(mgr1); 183 | if (re.test(w) && re2.test(w)) { 184 | re = /.$/; 185 | w = w.replace(re,""); 186 | } 187 | 188 | // and turn initial Y back to y 189 | if (firstch == "y") 190 | w = firstch.toLowerCase() + w.substr(1); 191 | return w; 192 | } 193 | } 194 | 195 | 196 | 197 | /** 198 | * Simple result scoring code. 199 | */ 200 | var Scorer = { 201 | // Implement the following function to further tweak the score for each result 202 | // The function takes a result array [filename, title, anchor, descr, score] 203 | // and returns the new score. 204 | /* 205 | score: function(result) { 206 | return result[4]; 207 | }, 208 | */ 209 | 210 | // query matches the full name of an object 211 | objNameMatch: 11, 212 | // or matches in the last dotted part of the object name 213 | objPartialMatch: 6, 214 | // Additive scores depending on the priority of the object 215 | objPrio: {0: 15, // used to be importantResults 216 | 1: 5, // used to be objectResults 217 | 2: -5}, // used to be unimportantResults 218 | // Used when the priority is not in the mapping. 219 | objPrioDefault: 0, 220 | 221 | // query found in title 222 | title: 15, 223 | // query found in terms 224 | term: 5 225 | }; 226 | 227 | 228 | /** 229 | * Search Module 230 | */ 231 | var Search = { 232 | 233 | _index : null, 234 | _queued_query : null, 235 | _pulse_status : -1, 236 | 237 | init : function() { 238 | var params = $.getQueryParameters(); 239 | if (params.q) { 240 | var query = params.q[0]; 241 | $('input[name="q"]')[0].value = query; 242 | this.performSearch(query); 243 | } 244 | }, 245 | 246 | loadIndex : function(url) { 247 | $.ajax({type: "GET", url: url, data: null, 248 | dataType: "script", cache: true, 249 | complete: function(jqxhr, textstatus) { 250 | if (textstatus != "success") { 251 | document.getElementById("searchindexloader").src = url; 252 | } 253 | }}); 254 | }, 255 | 256 | setIndex : function(index) { 257 | var q; 258 | this._index = index; 259 | if ((q = this._queued_query) !== null) { 260 | this._queued_query = null; 261 | Search.query(q); 262 | } 263 | }, 264 | 265 | hasIndex : function() { 266 | return this._index !== null; 267 | }, 268 | 269 | deferQuery : function(query) { 270 | this._queued_query = query; 271 | }, 272 | 273 | stopPulse : function() { 274 | this._pulse_status = 0; 275 | }, 276 | 277 | startPulse : function() { 278 | if (this._pulse_status >= 0) 279 | return; 280 | function pulse() { 281 | var i; 282 | Search._pulse_status = (Search._pulse_status + 1) % 4; 283 | var dotString = ''; 284 | for (i = 0; i < Search._pulse_status; i++) 285 | dotString += '.'; 286 | Search.dots.text(dotString); 287 | if (Search._pulse_status > -1) 288 | window.setTimeout(pulse, 500); 289 | } 290 | pulse(); 291 | }, 292 | 293 | /** 294 | * perform a search for something (or wait until index is loaded) 295 | */ 296 | performSearch : function(query) { 297 | // create the required interface elements 298 | this.out = $('#search-results'); 299 | this.title = $('

' + _('Searching') + '

').appendTo(this.out); 300 | this.dots = $('').appendTo(this.title); 301 | this.status = $('

').appendTo(this.out); 302 | this.output = $('