An open API service indexing awesome lists of open source software.

https://github.com/lispython/httphq

HTTP Request & Response service
https://github.com/lispython/httphq

Last synced: about 1 month ago
JSON representation

HTTP Request & Response service

Awesome Lists containing this project

README

        

HTTP Request & Response service
===============================

Simple service for testing HTTP/HTTPS requests.
All endpoint responses are JSON-encoded exclude `/status/{status_code: int} `_.
It's useful for testing how your own scripts deal with varying responses and requests.

.. image:: https://travis-ci.org/Lispython/httphq.png
:target: https://travis-ci.org/Lispython/httphq

INSTALLATION
------------

You can use ``easy_install`` or ``pip`` to install `httphq`:

``pip install httphq``

or

``easy_install httphq``

ENDPOINTS
---------

- `/ `_ — Show home page
- `/ip `_ — Returns client IP and proxies
- `/get `_ — GET method
- `/post `_ — POST method
- `/put `_ — PUT method
- `/head `_ — HEAD method
- `/options `_ — OPTIONS method
- `/delete `_ — DELETE method
- `/user-agent `_ — Returns user agent
- `/headers `_ — Returns sended headers
- `/cookies `_ — Returns all user cookies
- `/cookies/set/{name: str}/{value: str} `_ — Setup given name and value on client
- `/status/{status_code: int} `_ — Returns given HTTP status code
- `/basic-auth/{username: str}/{password: str} `_ — Basic access authentication
- `/digest-auth/{qop: auth | auth-int}/{username: str}/{password: str} `_ — Digest access authentication

HTTP status codes
-----------------

1xx Informational
~~~~~~~~~~~~~~~~~

- `100 `_ — Continue
- `101 `_ — Switching Protocols

2xx Success
~~~~~~~~~~~
- `200 `_ — OK
- `201 `_ — Created
- `202 `_ — Accepted
- `203 `_ — Non-Authoritative Information
- `204 `_ — No Content [ Won't return a response body ]
- `205 `_ — Reset Content [ Won't return a response body ]
- `206 `_ — Partial Content

3xx Redirection
~~~~~~~~~~~~~~~
- `300 `_ — Multiple Choices
- `301 `_ — Moved Permanently [ Will also return this extra header: Location: http://http.obout.ru ]
- `302 `_ — Found [ Will also return this extra header: Location: http://h.wrttn.me ]
- `303 `_ — See Other [ Will also return this extra header: Location: http://h.wrttn.me ]
- `304 `_ — Not Modified [ Won't return a response body ]
- `305 `_ — Use Proxy [ Will also return this extra header: Location: http://h.wrttn.me ]
- `306 `_ — (Unused)
- `307 `_ — Temporary Redirect [ Will also return this extra header: Location: http://h.wrttn.me ]

4xx Client Error
~~~~~~~~~~~~~~~~

- `400 `_ — Bad Request
- `401 `_ — Unauthorized [ Will also return this extra header: WWW-Authenticate: Basic realm="Fake Realm" ]
- `402 `_ — Payment Required
- `403 `_ — Forbidden
- `404 `_ — Not Found
- `405 `_ — Method Not Allowed
- `406 `_ — Not Acceptable
- `407 `_ — Proxy Authentication Required [ Will also return this extra header: Proxy-Authenticate: Basic realm="Fake Realm" ]
- `408 `_ — Request Timeout
- `409 `_ — Conflict
- `410 `_ — Gone
- `411 `_ — Length Required
- `412 `_ — Precondition Failed
- `413 `_ — Request Entity Too Large
- `414 `_ — Request-URI Too Long
- `415 `_ — Unsupported Media Type
- `416 `_ — Requested Range Not Satisfiable
- `417 `_ — Expectation Failed

5xx Server Error
~~~~~~~~~~~~~~~~

- `500 `_ — Internal Server Error
- `501 `_ — Not Implemented
- `502 `_ — Bad Gateway
- `503 `_ — Service Unavailable
- `504 `_ — Gateway Timeout
- `505 `_ — HTTP Version Not Supported

EXAMPLES
--------

.. code-block:: text

curl http://h.wrttn.me/get | python -mjson.tool
{
"args": {},
"headers": {
"Accept": "*/*",
"Host": "h.wrttn.me",
"User-Agent": "curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15"
},
"url": " http://h.wrttn.me/get"
}

curl -X POST -F "name=value" http://h.wrttn.me/post | python -mjson.tool
{
"args": {
"name": [
"value"
]
},
"body": "------------------------------eb288eb3d3e4\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nvalue\r\n------------------------------eb288eb3d3e4--\r\n",
"files": {},
"headers": {
"Accept": "*/*",
"Content-Length": "144",
"Content-Type": "multipart/form-data; boundary=----------------------------eb288eb3d3e4",
"Expect": "100-continue",
"Host": "h.wrttn.me",
"User-Agent": "curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15"
},
"ip": "127.0.0.1",
"request_time": 0.04458308219909668,
"start_time": 1313996082.806412,
"url": "http://h.wrttn.me/post"
}

curl -X POST -F "test_files=@/tmp/testfile1.txt" -F "test_files=@/tmp/testfile2.txt" http://h.wrttn.me/post | python -mjson.tool
{
"args": {},
"files": {
"pictures": [
{
"body": ";klrjewfghjnq3rjehg;fqnr___j3bnr4lgfbv4riy5bguy4br5y\n",
"content_type": "text/plain",
"filename": "testfile1.txt"
},
{
"body": ";klrlfkejwknfqwdrkjnbkfgjb3erj\n",
"content_type": "text/plain",
"filename": "testfile2.txt"
}
]
},
"body": "",
"headers": {
"Accept": "*/*",
"Content-Length": "428",
"Content-Type": "multipart/form-data; boundary=----------------------------af3ea881bfa9",
"Expect": "100-continue",
"Host": "h.wrttn.me",
"User-Agent": "curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15"
},
"ip": "127.0.0.1",
"request_time": 0.04804205894470215,
"start_time": 1313953495.331477,
"url": "http://h.wrttn.me/post"
}

SEE ALSO
--------

`http://hurl.it `_, `httpbin `_, `postbin `_, `ifconfig.me `_, `httpstat.us `_

CONTRIBUTE
----------

Fork https://github.com/Lispython/httphq/ , create commit and pull request.

THANKS
------

To `Kenneth Reitz `_ who develop `httpbin.org `_