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. }

    2.响应(ctx.response)的信息

    1. {
    2. status: 200,
    3. message: "OK",
    4. header: {
    5. content-type: "application/json; charset=utf-8"
    6. }
    7. }

    3.对两者的理解草图(浏览器-服务器为例子)

    ctx.request和ctx.response - 图1
    1.请求过程,服务器会接收到请求的信息
    2.相应过程,服务器将处理好的信息返回给浏览器