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. java实现 数据结构:链表、 栈、 队列、优先级队列、哈希表

    java实现 数据结构:链表. 栈. 队列.优先级队列.哈希表   数据结构javavector工作importlist 最近在准备找工作的事情,就复习了一下java.翻了一下书和网上的教材,发现虽然 ...

  2. Jupyter IPython dead kernel and do not restart

    本人遇到的情况:dead kernel & try to restart failed 查看CMD发现这个库安装有问题 解决办法 1.pip uninstall backports.shuti ...

  3. swiper 旋转木马效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  4. NOIP专题复习3 图论-强连通分量

    目录 一.知识概述 二.典型例题 1.[HAOI2006]受欢迎的牛 2.校园网络[[USACO]Network of Schools加强版] 三.算法分析 (一)Tarjan算法 (二)解决问题 四 ...

  5. 安装配置Keepalived

    一.在haproxy容器安装Keepalived 1.进入haproxy容器: docker exec -it h1 bash 2.apt-get update(因为haproxy容器为Ubuntu) ...

  6. buf.keys()

    buf.keys() 返回:{Iterator} 创建并返回一个包含 Buffer 键名(索引)的迭代器. const buf = Buffer.from('buffer'); for (var ke ...

  7. 编译时报错,找不到指定路径下的command,而路径是正确的。

    使用的Fedora 18 64位的系统kernel,内核为3.6.10.按照要求使用yum install *** 安装各项工具. path路径使用提供的toolchain,各种路径也安装正确,却发现 ...

  8. CodeForcesGym 100212E Long Dominoes

    Long Dominoes Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. ...

  9. poj1655(dfs,树形dp,树的重心)(点分治基础)

    题意:就是裸的求树的重心. #include<cstring> #include<algorithm> #include<cmath> #include<cs ...

  10. windows开启远程

    windows开启远程桌面超级简单,跟linux相比太简单了. 补充:有瑕疵,应该是远程中的远程桌面属性打钩,但是W8.1没有这个选项,W7可以,其次创建一个管理员账户,身份是管理员,不是标准用户,要 ...