美文网首页
发送http请求

发送http请求

作者: 很菜呀 | 来源:发表于2019-05-10 19:46 被阅读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
    

    相关文章

      网友评论

          本文标题:发送http请求

          本文链接:https://www.haomeiwen.com/subject/sujzoqtx.html