Comments (6)
我这儿没有问题:
exports.test = function*(){
this.body = yield this.proxy({test:'http://jsonplaceholder.typicode.com/users?_page=1'})
}
返回:
{
...
"headers": {
"date": "Sat, 18 Feb 2017 12:08:39 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"set-cookie": [
"__cfduid=dbcee87783db1b6e65be02b998ab2d43f1487419719; expires=Sun, 18-Feb-18 12:08:39 GMT; path=/; domain=.typicode.com; HttpOnly"
],
"x-powered-by": "Express",
"vary": "Accept-Encoding",
"access-control-allow-credentials": "true",
"cache-control": "public, max-age=14400",
"pragma": "no-cache",
"expires": "Sat, 18 Feb 2017 16:08:39 GMT",
"x-total-count": "10",
"access-control-expose-headers": "X-Total-Count, Link",
"link": "",
"x-content-type-options": "nosniff",
"etag": "W/\"160d-MxiAGkI3ZBrjm0xiEDfwqw\"",
"content-encoding": "gzip",
"via": "1.1 vegur",
"cf-cache-status": "EXPIRED",
"server": "cloudflare-nginx",
"cf-ray": "33315d9c91166d00-SJC"
},
...
from gracejs.
我这儿没有问题:
exports.test = function*(){
this.body = yield this.proxy({test:'http://jsonplaceholder.typicode.com/users?_page=1'})
}
返回:
{
...
"headers": {
"date": "Sat, 18 Feb 2017 12:08:39 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"set-cookie": [
"__cfduid=dbcee87783db1b6e65be02b998ab2d43f1487419719; expires=Sun, 18-Feb-18 12:08:39 GMT; path=/; domain=.typicode.com; HttpOnly"
],
"x-powered-by": "Express",
"vary": "Accept-Encoding",
"access-control-allow-credentials": "true",
"cache-control": "public, max-age=14400",
"pragma": "no-cache",
"expires": "Sat, 18 Feb 2017 16:08:39 GMT",
"x-total-count": "10",
"access-control-expose-headers": "X-Total-Count, Link",
"link": "",
"x-content-type-options": "nosniff",
"etag": "W/\"160d-MxiAGkI3ZBrjm0xiEDfwqw\"",
"content-encoding": "gzip",
"via": "1.1 vegur",
"cf-cache-status": "EXPIRED",
"server": "cloudflare-nginx",
"cf-ray": "33315d9c91166d00-SJC"
},
...
from gracejs.
估计你是想把其他的headers也返回给客户端吧?这种情况下建议最好别这么干~
from gracejs.
那我想要把其中的一个比如“x-total-count”返回,该怎么做呢
为什么不把所有的headers返回?
from gracejs.
目前头信息里只会解析set-cookies字段(即返回的cookie),不返回所有的headers有几方面的考虑:
1、数据就是数据,头信息就是头信息,所有的数据通过response body体传递,避免混用;
2、如果有多个并发请求的话,以哪个请求的头信息为准呢?
from gracejs.
恩,明白了,谢谢
请问一下我怎么附加信息到返回的headers中呢,我试了conf:{headers:{}} 没有作用
from gracejs.
Related Issues (20)
- 路由可以使用别的模式 HOT 1
- 多个post请求且有不同的form参数时,有好的解决方案吗? HOT 2
- Proxy-Post传XML参数时会被放进Form中。 HOT 1
- nunjucks 要添加个过滤器怎么加呢? HOT 1
- 模板引擎改为 nunjucks 出现找不到模板错误 HOT 1
- 建议添加 eslint, .editorconfig HOT 2
- proxy的500友好页怎么跳转
- controller 中如何某个引用的库 没有install 不报错,然后访问的时候404.有办法在编译的时候直接报错吗
- nunjucks 自定义过滤器 HOT 5
- 设置头字段中set-cookie为对应cookie 字段类型报错 HOT 1
- post支持xml吗 HOT 1
- proxy代理数据问题 HOT 1
- 数据库支持扩展 HOT 1
- `defaultCtrl.js` 里做鉴权时抛出`401`错误,无法进入default err handing! HOT 1
- 请问当页面输入URL地址时候如何把controller中的路由文件夹名字省略掉 HOT 2
- koa 新手求教
- 如何提高单点TPS, QPS HOT 5
- npm run dev 后 访问127.0.0.1:3000 报错 Cannot read property 'store' of undefined HOT 5
- session中间件报错,this.session是undefined HOT 2
- 运行start,页面返回Invalid hostname!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gracejs.