| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

类似cURL的CLI的Go语言实现:bat

CLI的Go语言实现,类似于cURL的工具。Bat能够用于测试、调试和与HTTP服务器交互。

主要特性

  • 直观的语法
  • 内置JSON 支持
  • 支持表单提交和文件上传
  • HTTPS, proxies, and authentication
  • 任意请求数据
  • 自定义headers

安装

go get -u github.com/astaxie/bat

make sure the$GOPATH/binis added into$PATH

使用

Hello World:

$ bat beego.me

Synopsis:

bat [flags] [METHOD] URL [ITEM [ITEM]]

See alsobat --help.

示例

Custom HTTP method, HTTP headers and JSON data:

$ bat PUT example.org X-API-Token:123 name=John

Submitting forms:

$ bat -form=true POST example.org hello=World

See the request that is being sent using one of the output options:

$ bat -v example.org

Use Github API to post a comment on an issue with authentication:

$ bat -a USERNAME POST https://api.github.com/repos/astaxie/bat/issues/1/comments body='bat is awesome!'

Upload a file using redirected input:

$ bat example.org < file.json

Download a file and save it via redirected output:

$ bat example.org/file > file

Download a file wget style:

$ bat --download example.org/file

Set a custom Host header to work around missing DNS records:

$ bat localhost:8000 Host:example.com

Following is the detailed documentation. It covers the command syntax, advanced usage, and also features additional examples.

HTTP 方法

The name of the HTTP method comes right before the URL argument:

$ bat DELETE example.org/todos/7

which looks similar to the actual Request-Line that is sent:

DELETE /todos/7 HTTP/1.1

When the METHOD argument is omitted from the command, bat defaults to either GET (if there is no request data) or POST (with request data).

项目主页:http://www.open-open.com/lib/view/home/1428629925046

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1428629925046.html
网络工具包 BAT