HTTPie

github

HTTPie 是用 Python 编写,用到了 Requests 和 Pygments 这些出色的库。

主要特性:

  • 直观的语法
  • 格式化和色彩化的终端输出
  • 内置 JSON 支持
  • 支持上传表单和文件
  • HTTPS、代理和认证
  • 随意请求数据
  • 自己定义头部
  • 持久性会话
  • 类 Wget 下载
  • 支持 Python 2.6, 2.7 和 3.x
  • 支持 Linux, Mac OS X 和 Windows
  • 插件
  • 文档
  • 測试覆盖率

安装


Mac
OS X

$ brew install httpie

Linux

# Debian-based distributions such as Ubuntu:
$ apt-get install httpie # RPM-based distributions:
$ yum install httpie

通过pip:

# Make sure we have an up-to-date version of pip and setuptools:
$ pip install --upgrade pip setuptools $ pip install --upgrade httpie

使用

hello world

$ http httpie.org

http --help

參考手冊

https://pypi.python.org/pypi/httpie

样例

  • 自己定义HTTP方法,HTTP header和JSON数据
$ http PUT example.org X-API-Token:123 name=John
  • 提交表单
$ http -f POST example.org hello=World
  • 打印发送请求使用的输出项
$ http -v example.org
  • 利用使用Github API公布评论和验证一个问题
$ http -a USERNAME POST https://api.github.com/repos/jakubroztocil/httpie/issues/83/comments body='HTTPie is awesome!'
  • 使用重定向输入上传一个文件
$ http example.org < file.json
  • 下载一个文件并通过重定向输出将其保存
$ http example.org/file > file

  • wget风格下载文件
$ http --download example.org/file
  • 使用session保持请求同样的主机之间的通信
$ http --session=logged-in -a username:password httpbin.org/get API-Key:123

$ http --session=logged-in httpbin.org/headers
  • 设置一个自己定义的主机头工作在失踪的DNS记录:
$ http localhost:8000 Host:example.com

HTTP Method

HTTP 请求方法位于 URL的左边,以下是使用DELETE方法进行请求

$ http DELETE example.org/todos/7

就像运行了以下的request-line命令行

DELETE /todos/7 HTTP/1.1

HTTPie 默认使用 GET (with no request data) 或者 POST (with request data).

Request URL

HTTPie 须要请求一个URL. 默认的 scheme 是 http://, 并且能够省略參数
– http ,
example.org就代表了
http://example.org,此外,支持curl类似的localhost, 比如  :3000
代表 http://localhost:3000,
默认是80port

$ http :/foo
GET /foo HTTP/1.1
Host: localhost
$ http :3000/bar
GET /bar HTTP/1.1
Host: localhost:3000
$ http :
GET / HTTP/1.1
Host: localhost

当手动在url中加入 querystring parameters , 能够直接使用 key==value

key==value  的形式而不用操心
& 符号.

$ http GET www.google.com search==HTTPie tbm==isch
GET /?

search=HTTPie&tbm=isch HTTP/1.1

HTTPie: a CLI, cURL-like tool for humans的更多相关文章

  1. HTTPie:替代 Curl 和 Wget 的现代 HTTP 命令行客户端

    HTTPie 工具是现代的 HTTP 命令行客户端,它能通过命令行界面与 Web 服务进行交互. -- Magesh Maruthamuthu 大多数时间我们会使用 curl 命令或是 wget 命令 ...

  2. cURL和HTTPie

    http://lingxiankong.github.io/blog/2014/08/19/curl-httpie/ 前两天在网上看到一个号称比cURL更牛逼的命令行工具HTTPie,提供命令行交互方 ...

  3. python笔记42-http请求命令行工具(httpie)

    前言 通常我们需要快速的测试某个接口通不通,一般linux上用curl去发http请求,但是这个命令行工具语法有点复杂了,不够直观. python有一个给人类使用的requests库,非常的简单方便. ...

  4. HTTP发包工具 -HTTPie

    原文: https://zm8.sm-tc.cn/?src=l4uLj8XQ0IuekZWWi5bRk5CZi5qN0ZyQktCPkIyL0M6cnMmcx8qdoM7PnMrIyMnI&u ...

  5. efcore dotnet cli add-migrations update-database

    add-migrations update-database 如何通过dotnet cli调用 dotnet tool install --global dotnet-ef dotnet ef mig ...

  6. [译][ABP vNext]ABP CLI,v0.18版本的新模板和其他功能

    ABP CLI,v0.18版本的新模板和其他功能 ABP v0.18已发布, 包含解决的70+个issue,500+次提交 网站更改 abp.io网站完全更新以突出ABP框架的目标和重要功能.文档和博 ...

  7. ABPHelper.CLI及其依赖项简单介绍

    目录 目录 ABPHelper.CLI 入门 使用指南 命令行 技术点如下 Scriban 通过Microsoft.Extensions.FileProviders.Embedded获取嵌入资源 通过 ...

  8. dotnet cli

    前言 dotnet cli (Command-Line Interface) .net 源代码和二进制文件管理工具.需要安装 .NET Core SDK. 终端执行 dotnet --info 可以打 ...

  9. Cheatsheet: 2015 08.01 ~ 08.31

    Java Beginner's Guide to MVC with Spring Framework Exploring the Spring Web MVC for Web Application ...

随机推荐

  1. javascript的prototype经典使用场景

    prototype的经典使用场景就是为对象增加属性和方法,如给自定义的Man对象增加个姓名属性和语言方法: function man() {        this.age = "22&qu ...

  2. aggregate和annotate方法使用详解与示例

    aggregate和annotate方法的使用场景 Django的aggregate和annotate方法属于高级查询方法,主要用于组合查询.当我们需要对查询集(queryset)的某些字段进行计算或 ...

  3. MongoDB数据库的安装

    首先就是MongoDB的下载,可以去MongoDB官网进行下载,https://www.mongodb.com/download-center/community,也可以通过百度网盘直接下载, 链接: ...

  4. 【Codeforces 492D】Vanya and Computer Game

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 第一个人攻击一次需要1/x秒 第二个人攻击一次需要1/y秒 这两个数字显然都是小数. 我们可以二分最后用了多少时间来攻击. 显然这个是有单调性 ...

  5. xcap发包工具的简单使用3(报文描述)

    之前详细介绍了如何构造以及发送报文,现在简单对报文描述一下 1.Ethernet MAC:填写报文目的mac和源mac地址 Vlan:支持单vlan,QinQ,如果有更多的vlan,请填写在“More ...

  6. Codeforces Round #352 (Div. 2),A题与B题题解代码,水过~~

    ->点击<- A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input s ...

  7. codeforces 359A

    #include<stdio.h> #define N 60 int map[N][N]; int main() {  int n,m,i,j,flag;  while(scanf(&qu ...

  8. bzoj 1005 [HNOI2008] 明明的烦恼 (prufer编码)

    [HNOI2008]明明的烦恼 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 5907  Solved: 2305[Submit][Status][Di ...

  9. es6异步编程 Promise 讲解 --------各个优点缺点总结

    //引入模块 let fs=require('fs'); //异步读文件方法,但是同步执行 function read(url) { //new Promise 需要传入一个executor 执行器 ...

  10. 【NOIP2017练习】函数变换(DP,dfs)

    题意: 思路: 极限步数大概不会超过30 ; ..max,..]of longint; eul:..max]of longint; cas,v,n,k,i,ans,j:longint; functio ...