跳转到主要内容

RESTful命令行HTTP客户端(比cURL更简单)。

项目描述

只是一个命令行HTTP客户端(遵循cURL的精神)。

示例用法

HTTP动词作为位置参数指定,后跟要操作的URL。目标是反映标准HTTP头的感觉。例如

$ http get http://localhost/

要提供请求体(例如POST或PUT),使用第三个位置参数

$ http post http://localhost/documents '{"json": "document"}' --content-type="application/json"

注意在末尾指定的任意请求头作为正常CLI选项。任何此类后续CLI选项都将作为请求头传递

$ http get http://localhost/ --x-forwarded-for=10.0.0.50

这将在随后的HTTP请求中转换为 X-Forwarded-For: 10.0.0.50。为了说明这一点,我们可以启用详细输出

$ http get http://localhost/ --x-forwarded-for=10.0.0.50
GET http://localhost/
X-Forwarded-For: 10.0.0.50

200 OK
Status: 200
Content-Length: 396
Content-Location: http://localhost/
Date: Wed, 30 May 2012 19:26:03 GMT
Content-Type: application/json

{
  "documents": [
    {
      "id": "c1be0fde3c0f4d27be15e1e3812cfd65b58325c3",
      "value": "a"
    },
    {
      "id": "67dc85dceacd3734ae53f1a69f56785dfe4c4c71",
      "value": "b"
    }
  ]
}

内置帮助

示例帮助输出

$ http --help
usage: http [-h] [-t] method url [body] ...

Python HTTP CLI Client

positional arguments:
  method       HTTP method to use (OPTIONS, GET, HEAD, POST, PUT, DELETE,
               TRACE, CONNECT)
  url          URL to work with
  body         Request body
  headers      Additional request headers (keyword=value)

optional arguments:
  -h, --help   show this help message and exit
  -t, --terse  Only show the response body

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

httpcli-1.3.0.tar.gz (3.4 kB 查看哈希值)

上传于 源代码

由以下支持