Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit d0b6255

Browse files
committed
Document CLI tools.
1 parent b44b699 commit d0b6255

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

docs/source/CLI.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
.. _CLI:
2+
3+
Hyper Command Line Interface
4+
============================
5+
6+
For testing purposes, ``hyper`` provides a command-line tool that can make
7+
HTTP/2 requests directly from the CLI. This is useful for debugging purposes,
8+
and to avoid having to use the Python interactive interpreter to execute basic
9+
queries.
10+
11+
The usage is::
12+
13+
hyper [-h] [--version] [--debug] [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
14+
15+
For example:
16+
17+
.. code-block:: bash
18+
19+
$ hyper GET https://nghttp2.org/httpbin/get
20+
{'args': {},
21+
'headers': {'Connection': 'close', 'Host': 'httpbin', 'Via': '2.0 nghttpx'},
22+
'origin': '81.129.184.72',
23+
'url': 'https://httpbin/get'}
24+
25+
This allows making basic queries to confirm that ``hyper`` is functioning
26+
correctly, or to perform very basic interop testing with other services.
27+
28+
Sending Data
29+
------------
30+
31+
The ``hyper`` tool has a limited ability to send certain kinds of data. You can
32+
add extra headers by passing them as colon-separated data:
33+
34+
.. code-block:: bash
35+
36+
$ hyper GET https://nghttp2.org/httpbin/get User-Agent:hyper/0.2.0 X-Totally-Real-Header:someval
37+
{'args': {},
38+
'headers': {'Connection': 'close',
39+
'Host': 'httpbin',
40+
'User-Agent': 'hyper/0.2.0',
41+
'Via': '2.0 nghttpx',
42+
'X-Totally-Real-Header': 'someval'},
43+
'origin': '81.129.184.72',
44+
'url': 'https://httpbin/get'}
45+
46+
You can add query-string parameters:
47+
48+
.. code-block:: bash
49+
50+
$ hyper GET https://nghttp2.org/httpbin/get search==hyper
51+
{'args': {'search': 'hyper'},
52+
'headers': {'Connection': 'close', 'Host': 'httpbin', 'Via': '2.0 nghttpx'},
53+
'origin': '81.129.184.72',
54+
'url': 'https://httpbin/get?search=hyper'}
55+
56+
And you can upload JSON objects:
57+
58+
.. code-block:: bash
59+
60+
$ hyper POST https://nghttp2.org/httpbin/post name=Hyper language=Python description='CLI HTTP client'
61+
{'args': {},
62+
'data': '{"name": "Hyper", "description": "CLI HTTP client", "language": '
63+
'"Python"}',
64+
'files': {},
65+
'form': {},
66+
'headers': {'Connection': 'close',
67+
'Content-Length': '73',
68+
'Content-Type': 'application/json; charset=utf-8',
69+
'Host': 'httpbin',
70+
'Via': '2.0 nghttpx'},
71+
'json': {'description': 'CLI HTTP client',
72+
'language': 'Python',
73+
'name': 'Hyper'},
74+
'origin': '81.129.184.72',
75+
'url': 'https://httpbin/post'}
76+
77+
Debugging and Detail
78+
--------------------
79+
80+
For more detail, passing the ``--debug`` flag will enable ``hyper``'s
81+
DEBUG-level logging. This provides a lot of low-level detail about exactly what
82+
``hyper`` is doing, including sent and received frames and HPACK state.
83+
84+
Notes
85+
-----
86+
87+
The ``hyper`` command-line tool is not intended to be a fully functional HTTP
88+
CLI tool: for that, we recommend using `HTTPie`_, which uses ``hyper`` for its
89+
HTTP/2 support.
90+
91+
.. _HTTPie: https://github.com/jakubroztocil/httpie-http2

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ More advanced topics are covered here.
5555
:maxdepth: 2
5656

5757
advanced
58+
CLI
5859

5960
Contributing
6061
------------

docs/source/quickstart.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,26 @@ you're interested in::
141141
>>> s.mount('https://www.twitter.com', a)
142142

143143
.. _requests: http://python-requests.org/
144+
145+
HTTPie Integration
146+
------------------
147+
148+
`HTTPie`_ is a popular tool for making HTTP requests from the command line, as
149+
an alternative to the ever-popular `cURL`_. Collaboration between the ``hyper``
150+
authors and the HTTPie authors allows HTTPie to support making HTTP/2 requests.
151+
152+
To add this support, follow the instructions in the `GitHub repository`_.
153+
154+
.. _HTTPie: http://httpie.org/
155+
.. _cURL: http://curl.haxx.se/
156+
.. _GitHub repository: https://github.com/jakubroztocil/httpie-http2
157+
158+
hyper CLI
159+
---------
160+
161+
For testing purposes, ``hyper`` provides a command-line tool that can make
162+
HTTP/2 requests directly from the CLI. This is useful for debugging purposes,
163+
and to avoid having to use the Python interactive interpreter to execute basic
164+
queries.
165+
166+
For more information, see the CLI section.

0 commit comments

Comments
 (0)