1.请求(ctx.request)的信息

    1. {
    2. method: "GET",
    3. url: "/",
    4. header: {
    5. host: "localhost:3000",
    6. connection: "keep-alive",
    7. cache-control: "max-age=0",
    8. upgrade-insecure-requests: "1",
    9. user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
    10. accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    11. accept-encoding: "gzip, deflate, br",
    12. accept-language: "zh-CN,zh;q=0.9,en;q=0.8"
    13. }
    14. }
    15. f

    2.返回请求协议类型(ctx.protocol),浏览器中输入请求
    ctx.request => ctx.protocol和ctx.secure - 图1
    完整域名:http://localhost:3000/inde.html?username=ziye&pwd=123456

    测试结果

    1. http

    3.this.protocol==”https”的返回值结果(布尔) (ctx.secure),一个判断是否为https的布尔结果
    现在的测试结果是http请求过去,结果如下

    1. false