Coder Social home page Coder Social logo

Comments (6)

xiongwilee avatar xiongwilee commented on August 26, 2024

我这儿没有问题:

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.

xiongwilee avatar xiongwilee commented on August 26, 2024

我这儿没有问题:

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.

xiongwilee avatar xiongwilee commented on August 26, 2024

估计你是想把其他的headers也返回给客户端吧?这种情况下建议最好别这么干~

from gracejs.

qppq54s avatar qppq54s commented on August 26, 2024

那我想要把其中的一个比如“x-total-count”返回,该怎么做呢
为什么不把所有的headers返回?

from gracejs.

xiongwilee avatar xiongwilee commented on August 26, 2024

目前头信息里只会解析set-cookies字段(即返回的cookie),不返回所有的headers有几方面的考虑:
1、数据就是数据,头信息就是头信息,所有的数据通过response body体传递,避免混用;
2、如果有多个并发请求的话,以哪个请求的头信息为准呢?

from gracejs.

qppq54s avatar qppq54s commented on August 26, 2024

恩,明白了,谢谢
请问一下我怎么附加信息到返回的headers中呢,我试了conf:{headers:{}} 没有作用

from gracejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.