【发布时间】:2015-08-22 01:11:39
【问题描述】:
我想使用 API 的 GitHub 版本中的 http.get 方法在 Node.js 中编写一个自动下载器,我收到 302 错误。我能做什么?
【问题讨论】:
标签: node.js github github-api nw.js
我想使用 API 的 GitHub 版本中的 http.get 方法在 Node.js 中编写一个自动下载器,我收到 302 错误。我能做什么?
【问题讨论】:
标签: node.js github github-api nw.js
HTTP 302 不是错误:
HTTP 响应 status code 302 Found 是执行URL redirection 的常用方式。
您可以通过检索 Location 响应标头中显示的 URL 来处理 HTTP 302 Found。
您可能要考虑使用the request library,而不是使用http.get,如this answer 中的建议。 request 应该会自动跟随重定向。
【讨论】: