http接口测试

想测试接口功能,get 请求还能在浏览器地址栏敲敲,测测,post怎么模拟?

找到两个不错的方法,一是postman; 二是使用curl

postman

chrome 添加postman interceptor, postman插件:

postman插件.png

打开postman, 选择create new => create a basic request


image.png

可以创建collection,类似于用文件夹来管理你的各种请求, 随后输入请求方式,参数,点击send就可以模拟发送请求了,下方就是response。postman, 你值得拥有


image.png

curl

百科一下:

curl是利用URL语法在命令行方式下工作的开源文件传输工具。它被广泛应用在Unix、多种Linux发行版中,并且有DOS和Win32、Win64下的移植版本。

常用的参数:

-d/ --data curl 默认是get, -d/ —data可以指定post 传递的数据

-H/--header 自定义头信息传递给服务器

-o -- output 将输出写到该文件中

-O -- remote-name 将输出写到该文件中 保留远程文件名

-T 上传文件

举个栗子:
curl http://localhost:8080/test
curl -d "x=1" http://localhost:8080/test
curl -H '' "x=1" http://localhost:8080/test

你可能感兴趣的:(http接口测试)