mirror of
https://github.com/strapi/strapi.git
synced 2025-08-19 14:19:03 +00:00
1 line
163 KiB
JavaScript
1 line
163 KiB
JavaScript
![]() |
(window.webpackJsonp=window.webpackJsonp||[]).push([[51],{188:function(t,s,a){"use strict";a.r(s);var e=a(0),n=Object(e.a)({},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"content"},[t._m(0),t._v(" "),a("p",[t._v("See the "),a("router-link",{attrs:{to:"./../concepts/concepts.html#responses"}},[t._v("responses concepts")]),t._v(" for details.")],1),t._v(" "),t._m(1),t._v(" "),a("p",[t._v("For more information, please refer to the "),a("a",{attrs:{href:"http://koajs.com/#response",target:"_blank",rel:"noopener noreferrer"}},[t._v("Koa response documentation"),a("OutboundLink")],1),t._v(".")]),t._v(" "),t._m(2),t._v(" "),a("p",[t._v("The context object ("),a("code",[t._v("ctx")]),t._v(") contains a list of values and functions useful to manage server responses. They are accessible through "),a("code",[t._v("ctx.response")]),t._v(", from "),a("router-link",{attrs:{to:"./controllers.html"}},[t._v("controllers")]),t._v(" and "),a("router-link",{attrs:{to:"./policies.html"}},[t._v("policies")]),t._v(".")],1),t._v(" "),t._m(3),t._v(" "),a("p",[t._v("Response header object.")]),t._v(" "),t._m(4),t._v(" "),t._m(5),t._v(" "),t._m(6),t._v(" "),a("p",[t._v("Request socket.")]),t._v(" "),t._m(7),t._v(" "),t._m(8),t._v(" "),t._m(9),t._v(" "),a("p",[t._v("Set response status via numeric code:")]),t._v(" "),t._m(10),t._v(" "),t._m(11),t._v(" "),t._m(12),t._v(" "),t._m(13),t._v(" "),t._m(14),t._v(" "),a("p",[t._v("Set response status message to the given value.")]),t._v(" "),t._m(15),t._v(" "),a("p",[t._v("Set response Content-Length to the given value.")]),t._v(" "),t._m(16),t._v(" "),t._m(17),t._v(" "),t._m(18),t._v(" "),a("p",[t._v("Get response body.")]),t._v(" "),t._m(19),t._v(" "),a("p",[t._v("Set response body to one of the following:")]),t._v(" "),t._m(20),t._v(" "),t._m(21),t._v(" "),t._m(22),t._v(" "),a("p",[t._v("The Content-Type is defaulted to text/html or text/plain, both with\na default charset of utf-8. The Content-Length field is also set.")]),t._v(" "),t._m(23),t._v(" "),a("p",[t._v("The Content-Type is defaulted to application/octet-stream, and Content-Length\nis also set.")]),t._v(" "),t._m(24),t._v(" "),a("p",[t._v("The Content-Type is defaulted to application/octet-stream.")]),t._v(" "),t._m(25),t._v(" "),a("p",[t._v("See: https://github.com/koajs/koa/pull/612 for more information.")]),t._v(" "),a("p",[t._v("Here's an example of stream error handling without automatically destroying the stream:")]),t._v(" "),t._m(26),t._m(27),t._v(" "),t._m(28),t._v(" "),t._m(29),t._v(" "),t._m(30),t._v(" "),t._m(31),t._m(32),t._v(" "),t._m(33),t._v(" "),t._m(34),t._m(35),t._v(" "),t._m(36),t._v(" "),t._m(37),t._m(38),t._v(" "),t._m(39),t._v(" "),t._m(40),t._m(41),t._v(" "),t._m(42),t._v(" "),t._m(43),t._v(" "),t._m(44),t._v(" "),t._m(45),t._m(46),t._v(" "),t._m(47),t._v(" "),t._m(48),t._m(49),t._v(" "),t._m(50),t._v(" "),t._m(51),t._v(" "),a("p",[t._v("For example, this is a middleware that minifies\nall HTML responses except for streams.")]),t._v(" "),t._m(52),t._m(53),t._v(" "),t._m(54),t._v(" "),t._m(55),t._v(" "),t._m(56),t._m(57),t._v(" "),t._m(58),t._m(59),t._v(" "),t._m(60),t._v(" "),t._m(61),t._v(" "),a("p",[t._v("Check if a response header has already been sent. Useful for seeing\nif the client may be notified on error.")]),t._v(" "),t._m(62),t._v(" "),t._m(63),t._v(" "),t._m(64),t._v(" "),t._m(65),t._v(" "),t._m(66),t._m(67),t._v(" "),t._m(68),t._v(" "),t._m(69),t._m(70),t._v(" "),t._m(71),t._v(" "),t._m(72),t._v(" "),a("p",[t._v("Flush any set headers, and begin the body.")]),t._v(" "),t._m(73),t._v(" "),t._m(74),t._v(" "),t._m(75),t._v(" "),t._m(76),t._v(" "),a("p",[t._v("Response header object.")]),t._v(" "),t._m(77),t._v(" "),t._m(78),t._v(" "),t._m(79),t._v(" "),a("p",[t._v("Request socket.")]),t._v(" "),t._m(80),t._v(" "),t._m(81),t._v(" "),t._m(82),t._v(" "),a("p",[t._v("Set response status via numeric code:")]),t._v(" "),t._m(83),t._v(" "),t._m(84),t._v(" "),t._m(85),t._v(" "),t._m(86),t._v(" "),t._m(87),t._v(" "),a("p",[t._v("Set response status message to the given value."
|