Linux下模拟http的get/post请求(curl or wget)详解
2017-05-10 16:00
816 查看
Linux下模拟http的get/post请求(curl or wget)详解
背景
最近项目中需要测试接口,但是测试服务器通过堡垒机才能访问,暂时又没有通过Nginx进行转发,只好直接在Linux上模拟http请求进行测试。
方法
get请求
curl “http://www.baidu.com” 如果URL指向的是一个文件或者一幅图可以直接下载到本地
curl -i “http://www.baidu.com” 显示全部信息
curl -l “http://www.baidu.com” 只显示头部信息
curl -v “http://www.baidu.com” 显示get请求全过程解析
wget “http://www.baidu.com”
post请求
curl -d “param1=value1¶m2=value2” “http://www.baidu.com”
通过-d参数,把访问参数放在里面,如果没有参数,则不需要-d。
wget –post-data ‘user=foo&password=bar' http://www.baidu.com
curl和wget区别
经实践,curl模拟的访问请求一般直接在控制台显示,而wget则把结果保存为一个文件。如果结果内容比较少,需要直接看到结果可以考虑使用curl进行模拟请求,如果返回结果比较多,则可考虑wget进行模拟请求。
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章推荐
- Linux下模拟http的get/post请求(curl or wget)
- Linux下模拟http的get/post请求(curl or wget)
- Linux 下模拟Http 的get or post请求(curl和wget两种方法)
- Linux 下模拟Http 的get or post请求(curl和wget两种方法)
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求。
- Linux 下curl模拟Http 的get or post请求。
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求。
- Linux 下curl模拟Http 的get or post请求
- Linux 下curl模拟Http 的get or post请求。
- Linux命令发送Http的get或post请求(curl和wget两种方法)
- linux命令发送http的get或post请求(curl和wget两种方法)
- curl模拟Http 的get or post请求
- Linux命令发送Http的get或post请求(curl和wget两种方法)
- PHP之文件操作,http请求数据格式,模拟get和post,CURL模拟请求的使用
- Linux下开发常用 模拟 Http get和post请求