美文网首页KOA
6.3KOA 数据响应 Response

6.3KOA 数据响应 Response

作者: 帶頭二哥 | 来源:发表于2020-01-06 02:00 被阅读0次

数据响应 Response

获取 Response 对象
router.post('/',async (ctx,next) => {
    // 获取数据响应对象
    let response = ctx.response
    // 设置响应内容
    response.body = "Hello World" 
    // 等价于 ctx.body = "Hello World"
    // ...

    // 响应头
    response.headers 

    // 响应状态
    response.status // 别名 ctx.status
    // 重定向
    response.redirect(url, [alt]) // 别名 ctx.redirect
    // 获取响应 Content-Type 不含参数 "charset"。
    response.type // 别名 ctx.type
})

API详细地址

Response 别名
  • ctx.body
  • ctx.body=
  • ctx.status
  • ctx.status=
  • ctx.message
  • ctx.message=
  • ctx.length=
  • ctx.length
  • ctx.type=
  • ctx.type
  • ctx.headerSent
  • ctx.redirect()
  • ctx.attachment()
  • ctx.set()
  • ctx.append()
  • ctx.remove()
  • ctx.lastModified=
  • ctx.etag=
响应状态码说明
  • 100 "continue"
  • 101 "switching protocols"
  • 102 "processing"
  • 200 "ok"
  • 201 "created"
  • 202 "accepted"
  • 203 "non-authoritative information"
  • 204 "no content"
  • 205 "reset content"
  • 206 "partial content"
  • 207 "multi-status"
  • 208 "already reported"
  • 226 "im used"
  • 300 "multiple choices"
  • 301 "moved permanently"
  • 302 "found"
  • 303 "see other"
  • 304 "not modified"
  • 305 "use proxy"
  • 307 "temporary redirect"
  • 308 "permanent redirect"
  • 400 "bad request"
  • 401 "unauthorized"
  • 402 "payment required"
  • 403 "forbidden"
  • 404 "not found"
  • 405 "method not allowed"
  • 406 "not acceptable"
  • 407 "proxy authentication required"
  • 408 "request timeout"
  • 409 "conflict"
  • 410 "gone"
  • 411 "length required"
  • 412 "precondition failed"
  • 413 "payload too large"
  • 414 "uri too long"
  • 415 "unsupported media type"
  • 416 "range not satisfiable"
  • 417 "expectation failed"
  • 418 "I'm a teapot"
  • 422 "unprocessable entity"
  • 423 "locked"
  • 424 "failed dependency"
  • 426 "upgrade required"
  • 428 "precondition required"
  • 429 "too many requests"
  • 431 "request header fields too large"
  • 500 "internal server error"
  • 501 "not implemented"
  • 502 "bad gateway"
  • 503 "service unavailable"
  • 504 "gateway timeout"
  • 505 "http version not supported"
  • 506 "variant also negotiates"
  • 507 "insufficient storage"
  • 508 "loop detected"
  • 510 "not extended"
  • 511 "network authentication required"

相关文章

  • 6.3KOA 数据响应 Response

    数据响应 Response 获取 Response 对象 API详细地址 Response 别名 ctx.body...

  • Servlet

    响应数据【响应数据的方式】 1)response.getWrite().print(“响应到页面显示的内容”);2...

  • response

    1.设置浏览器响应数据的类型用response.setContentType(); 有response.setCo...

  • JavaWeb--Request&Response

    Request:获取请求数据Response:设置响应数据 Request继承体系:ServletRequest-...

  • Response&Request&Http

    Response1.响应消息(response)组成:响应行,响应头,响应空行,响应体2.响应行组成:协议/版本 ...

  • 12-码蚁JavaWeb之Response

    一、response响应过程 牢记响应的流程图 二、学习响应 通过response设置响应行,响应头 ,响应体 设...

  • 已知url逆向获取请求头信息

    response响应对象的常用属性 response.url:当前响应的url地址 response.reques...

  • 2018-07-20

    response对象输出响应信息 response.getCharacterEncoding()响应的字符编码集 ...

  • Servlet学习3 -- Response对象和Servlet

    一.Response对象 Response的作用Response对象是用来设置HTTP响应消息的,包括了响应行,响...

  • http响应

    1.包含 响应头、响应体、响应代码 2.response status code 3.response heade...

网友评论

    本文标题:6.3KOA 数据响应 Response

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