Open
Conversation
加入说明性文档,添加MDN链接,加入一些tips,去除测试语句
atian25
requested changes
Jan 21, 2020
|
|
||
| 对应的测试: | ||
|
|
||
| ```js |
| 除了 `状态码` 和 `响应体` 外,还可以通过响应 `Header` 设置一些扩展信息。 | ||
| 设置应答包的 `HTTP Header` | ||
|
|
||
| 关于`HTTP Header`本身,可以查看[MDN的HTTP headers文档](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers)\ |
Member
There was a problem hiding this comment.
中文英文排版要有空格,参考下 https://github.com/sparanoid/chinese-copywriting-guidelines
|
|
||
| ### `ctx.set(name, value)` | ||
|
|
||
| 除了 `状态码` 和 `响应体` 外,还可以通过响应 `Header` 设置一些扩展信息。 |
| 关于`HTTP Header`本身,可以查看[MDN的HTTP headers文档](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers)\ | ||
| 每个`HTTP Header`通常说明应答的资源本体(HTTP body)的属性,或者控制浏览器对该资源的一些行为(如缓存等) | ||
|
|
||
| > egg本身会自动添加必要的`header`(比如返回json时自动设置 `content-type`为 `application/json; charset=utf-8`,说明该资源为json类型和utf-8字符编码),另外public路径下的文件也会自动加入缓存时间(参考[egg-static](https://github.com/eggjs/egg-static)) |
|
|
||
| > egg本身会自动添加必要的`header`(比如返回json时自动设置 `content-type`为 `application/json; charset=utf-8`,说明该资源为json类型和utf-8字符编码),另外public路径下的文件也会自动加入缓存时间(参考[egg-static](https://github.com/eggjs/egg-static)) | ||
|
|
||
| 如果需要便捷设置资源类型的header(`content-type`),可以查看下面的 `ctx.type` 文档 |
|
|
||
| - `ctx.set(key, value)`:可以设置一个 `Header`。 | ||
| - `ctx.set(headers)`:可以同时设置多个 `Header`。 | ||
| - `ctx.set(headers)`:可以同时设置多个 `Header`,多个header使用对象的方式组合,如`{'key1':'value1', 'key2':'value2'}` |
|
这个文档不更新了吗 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
加入说明性文档,添加MDN链接,加入一些tips,去除测试语句