- postman
- nc
- curl
- bat
在进行web开发或者接口调试的时候,免不了要进行模拟http请求,以查看服务端是否正常
postman
postman提供有模拟web server,仅仅作为开发使用啊,因为速度稳定性都太差了
nc
>>> while true; do echo -e "HTTP/1.1 200 OK\n\n ❤" | nc -l -p 8080 -q 1; done
# 如果不用返回
>>> nc -l -p 8080
参考:
https://stackoverflow.com/a/16640233/7151777
https://www.jianshu.com/p/dc4b966a4062
>>> nc localhost 8080
HTTP/1.1 200 OK
❤
curl
>>> curl 127.0.0.1:8080
❤
bat
bat是Golong大神谢孟军用Go写的类似cURL的请求工具,特点就是输出比curl更人性化
>>> git clone https://github.com/astaxie/bat.git
>>> cd bat
>>> docker build -t astaxie/bat .
>>> docker run --rm -it --net=host astaxie/bat 127.0.0.1:8080
GET / HTTP/1.1
Host: 127.0.0.1:1500
Accept: application/json
Accept-Encoding: gzip, deflate
User-Agent: bat/0.1.0
HTTP/1.1 200 OK
❤
关于http基础知识可以参考:
https://zhuanlan.zhihu.com/p/41332273