Metadata-Version: 2.1
Name: har-server
Version: 0.0.1
Summary: Programmable HTTP server for testing
Home-page: https://github.com/dave-shawley/har-server
Author: Dave Shawley
Author-email: daveshawley+harserver@gmail.com
License: UNKNOWN
Project-URL: Builds, https://circleci.com/gh/dave-shawley/har-server/
Project-URL: Coverage Reports, https://coveralls.io/github/dave-shawley/har-server
Project-URL: Documentation, http://har-server.readthedocs.io/
Project-URL: Source Code, https://github.com/dave-shawley/har-server/
Platform: UNKNOWN
Classifier: Development Status :: 1 - Planning
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Testing :: Mocking
Requires-Dist: aiohttp (==3.4.4)
Requires-Dist: yarl (==1.3.0)
Provides-Extra: dev
Requires-Dist: coverage (==4.5.2) ; extra == 'dev'
Requires-Dist: coveralls (==1.5.1) ; extra == 'dev'
Requires-Dist: flake8 (==3.6.0) ; extra == 'dev'
Requires-Dist: nose (==1.3.7) ; extra == 'dev'
Requires-Dist: pycodestyle (==2.4.0) ; extra == 'dev'
Requires-Dist: pyflakes (==2.0.0) ; extra == 'dev'
Requires-Dist: Sphinx (==1.8.2) ; extra == 'dev'
Requires-Dist: twine (==1.12.1) ; extra == 'dev'
Requires-Dist: wheel (==0.32.3) ; extra == 'dev'
Requires-Dist: yapf (==0.25.0) ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: Sphinx (==1.8.2) ; extra == 'docs'

==========
HAR Server
==========
Simple programmable HTTP API server.

|build| |coverage| |docs|

The server is programmable using elements from the `HTTP Archive`_ (HAR)
specification originally developed by `Jan Odvarko`_ and the `W3C`_
web-performance working group.  It was never moved beyond draft in the
W3C.  Jan Odvarko has maintained the specification on his blog.  I created
this project after discovering the `mockbin`_ service created by `Mashape`_
(now `KongHQ`_).  Unfortunately `mockbin`_ does not meet my exact needs.

Usage
=====
The primary use case is to return programmed responses to specified
requests.  The response is POSTed to service along with a matching request.
Both are specified as HAR objects -- the request is a `HAR request`_ and
the response is a `HAR response`_ ::

   POST /responses HTTP/1.1
   Host: 127.0.0.1:8080
   Content-Type: application/json
   Content-Length: 733

   {
      "request": {
         "method": "GET",
         "url": "http://example.org/status",
         "httpVersion": "HTTP/1.1",
         "cookies": [],
         "headers": [],
         "queryString": [],
         "postData": {},
         "headersSize": -1,
         "bodySize": 0
      },
      "response": {
         "status": 200,
         "statusText": "OK",
         "httpVersion": "HTTP/1.1",
         "cookies": [],
         "headers": [
            {"name":"Content-Type", "value":"application/json"}
         ],
         "content": {
            "mimeType": "application/json",
            "encoding": "json",
            "text": {
               "service": "my-service",
               "status": "ok"
            }
         },
         "redirectURL": "",
         "headersSize": -1,
         "bodySize": -1
      }
   }

   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 49
   Link: <http://127.0.0.1:8080/hosts>; rel=host-map; method=GET
   Link: <http://127.0.0.1:8080/requests>; rel=requests; method=GET
   Link: <http://127.0.0.1:8080/responses>; rel=add-response; method=POST
   Link: <http://127.0.0.1:8080/responses>; rel=clear-responses;
     method=PURGE

   {
      "effective_url": "http://127.0.0.1:32443"
   }

After this message is sent, the service will respond to ``GET /status``
on port 32443 with the registered response::

   GET /status HTTP/1.1
   Host: 127.0.0.1:32443

   HTTP/1.1 200 OK
   Content-Type: application/json

   {
     "service": "my-service",
     "status": "ok"
   }

.. _HAR request: http://www.softwareishard.com/blog/har-12-spec/#request
.. _HAR response: http://www.softwareishard.com/blog/har-12-spec/#response
.. _HTTP Archive: http://www.softwareishard.com/blog/har-12-spec/
.. _Jan Odvarko: http://www.softwareishard.com/blog/about/
.. _KongHQ: https://konghq.com/
.. _Mashape: https://en.wikipedia.org/wiki/Mashape
.. _mockbin: https://mockbin.com/
.. _W3C: https://w3c.github.io/web-performance/specs/HAR/Overview.html

.. |build| image:: https://circleci.com/gh/dave-shawley/har-server/tree/master.svg?style=svg
   :target: https://circleci.com/gh/dave-shawley/har-server/tree/master
.. |coverage| image:: https://coveralls.io/repos/github/dave-shawley/har-server/badge.svg?branch=master
   :target: https://coveralls.io/github/dave-shawley/har-server?branch=master
.. |docs| image:: https://readthedocs.org/projects/har-server/badge/?version=latest
   :target: https://har-server.readthedocs.io/en/latest/?badge=latest


