发送http请求

2019-05-10  本文已影响0人  很菜呀

发送http请求

# 指定服务器地址
curl -v -x 127.1:8000 http://a.aa.com/index.html  

# 保存响应内容到a
curl -voa http://127.0.0.1:8000/index.html -H "host:a.aa.com"  

# https请求,不校验证书
curl -v https://127.0.0.1:443/index.html -v -k -H "host:www.mytest.com"

# 使用openssl发送https请求
openssl s_client -connect 127.0.0.1:443
GET https://a.aa.com/index.html HTTP/1.1

发送http2请求

参考链接:curl支持h2: https://segmentfault.com/a/1190000004553963

# 安装了nghttp2
./nghttp -nuv https://www.dianrong.com/ --ip 10.8.204.141 --port=443  --check-sni

发送websocket请求

  1. 先开启服务端,nc模拟,先键入应答
  2. 再启动客户端,发起websocket请求
# 启动服务端
nc -l -v 9000

Connection
HTTP/1.0 101 Switching Protocols
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Location: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Origin: chat

abcdrfghijklmnop

# 启用客户端
telnet 127.0.0.1 9000
GET ws://www.ng2.com/ HTTP/1.1
Host: www.ng2.com
Sec-WebSocket-Key1: sBcNTmACQ0ui3zHHn4T5aA==
Sec-WebSocket-Key2: chat, superchat
Sec-WebSocket-Version: 0
Upgrade: websocket
Connection: Upgrade

12345678
上一篇下一篇

猜你喜欢

热点阅读