不确定这是浏览器还是node.js。
我正在设置(实际上oauth2orize是)位置标头为https://localhost:4000...
,调试语句清楚地显示了这一点。这是来自https请求。
然而,在浏览器中,它显示为位置:http://localhost:4000....
我甚至在响应之前将“垃圾”粘贴到结尾,它正好在标题中,但https正在更改为http。< / p>
我在这里使用代理,但我怀疑它是否在乎,因为它似乎可以很好地传递其他重定向。
var location = "https://localhost:4000/dashboard#access_token=BIJs8aOamYbfvz9IqCQkkhgFTnp8vvmAXmTzr6bGZSTKvQIfVP627IPXu2ZHQrQqMvDWrvtZe1aX4zR5cbmrcjLtzyUKP9PEn8XVLC43hDW8HHdmMc70YaWDMzgmueLqc9y0IqKewxmCbqkpqfPdRQ1FssyMdWfnNExowTzSU1wuIFEahUSKGg64Ip8aJzngdyKEluWNDxchaRXBsDEBPR0tvR2Eb1h9yPgkaY0ssIbYLnnFwyXwj13AThCZYacH&expires_in=3599&scope=profile&token_type=bearer"
res.statusCode = 302;
res.setHeader("Location", location + "junk");
res.setHeader("Content-Type", 'text/plain');
res.end('<p>302. Redirecting to ' + location + '</p>');
在我得到的浏览器中:
Request URL:https://localhost:4000/oauth/dialog/authorize/decision
Request Method:POST
Status Code:302 Moved Temporarily
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:35
Content-Type:application/x-www-form-urlencoded
Cookie:splashShown1.6=1; undefined=0; csrftoken=tuY3Uoh3DDfctJ92Hbjq1070072ZNwXl; connect.sess=s%3Aj%3A%7B%22passport%22%3A%7B%7D%7D.Y%2FN8%2F6JZIdX2TJ%2BTKGLvw0Fxbthv7AppwHR0GLB0EpI; connect.sid=s%3AXRVtIjxoIjzwkoCSw4tJpgBW.%2BCFrYUVKQgNoUZjUCtBopglk%2F0GHmXukTJ0UNBJZHIc
Host:localhost:4000
Origin:https://localhost:4000
Referer:https://localhost:4000/oauth/authorize?response_type=token&client_id=v10data_dashboard&redirect_uri=https://localhost:4000/dashboard
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Form Dataview sourceview URL encoded
transaction_id:xP7l0zTn
allow:allow
Response Headers
connection:keep-alive
content-type:text/plain
date:Thu, 26 Sep 2013 16:27:00 GMT
location:http://localhost:4000/dashboard#access_token=P40W1mZvSTUUk...OcsIQ9S4&expires_in=3599&scope=profile&token_type=bearerjunk
transfer-encoding:chunked
x-powered-by:Express
更新
我已经阅读了303和307重定向代码,在尝试303后,它可以正常工作!为什么?我仍然不是很确定,仍然试图弄清楚规格,因为看起来浏览器以稍微不同的方式实现,但现在它们大多数都是这样做的,部分规格被忽略......非常令人困惑。
我也在Firefox中尝试过,302和303都提供了与Chrome相同的结果(就像上面显示的示例结果一样)。