Skip to main content

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"
}

Metadata

Release files for har-server 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for har-server 0.0.1
File Size Uploaded
har-server-0.0.1.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for har-server 0.0.1
File Interpreter ABI Platform
har_server-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / har-server-0.0.1.tar.gz

Download URL har-server-0.0.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a5924d7394db5df53eb12092285e3de7d2f97e746c520cb70ecdcdb7f89dc37e
BLAKE2b-256 checksum
How to use checksums
ec65d2d8a4fb8a4933eb2bf744324be2842e14afad46f8fe5687f3c4a7781a52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / har_server-0.0.1-py3-none-any.whl

Download URL har_server-0.0.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92aa55b9d9c962d5c72a5ba4079997a11fde4114df1ff3ce4e12fe2dfd816416
BLAKE2b-256 checksum
How to use checksums
5e3aa40616a2ad208035709f1fb392dad65d45b0981925ca24373687d5f15c8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page