node.js - 使用pastebin API时nodejs http_outgoing崩溃

标签 node.js pastebin

我编写了一个 Node 应用程序,它除了其他很酷的功能外,还提供了一个指向该应用程序从 txt 文件创建的 Pastebin 的链接。

它在我的 OS X 上的本地 MacBook 上完美运行。但是在我租用的 debian 服务器上,当有人请求指向 Pastebin 的链接/请求应用程序创建一个 Pastebin 时,就会出现这种情况

编辑:我之前也在我的服务器上运行过此功能。现在我只是在单独的模块中重新安排了一些代码,例如connection.js、database.js 等

我用#pastebin#替换了pastebin模块路径,如果需要的话我会重新添加它们。但所有这些都链接到pastebin-js/node_modules/request/request.js 中的内容

这是我用于pastebin的库:https://github.com/j3lte/pastebin-js

_http_outgoing.js:339
        throw new TypeError(
        ^

    TypeError: Header name must be a valid HTTP Token ["Cache-Control:"]
        at ClientRequest.OutgoingMessage.setHeader (_http_outgoing.js:339:11)
        at new ClientRequest (_http_client.js:86:14)
        at Object.exports.request (http.js:31:10)
        at Request.start (#pastebin#)
        at Request.write (#pastebin#)
        at end (#pastebin#)
        at #pastebin#
        at doNTCallback0 (node.js:428:9)
        at process._tickCallback (node.js:357:13)

最佳答案

所以我想我找到了我的问题。

我必须升级服务器上的 Node ,因为由于某种原因, module.exports 和多个导出的语法未知。

5.0 版本太高后,我现在似乎降级到 v4.2.1,效果很好。

关于node.js - 使用pastebin API时nodejs http_outgoing崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33596103/

相关文章:

javascript - Socket.io : "Cannot read property ' emit' of undefined"

node.js - 使用 docker-compose 在 dockerized node.js 应用程序中重新加载代码

带有 PasteBin API 的 jQuery $.post

http - 通过 API 编辑现有的 Pastebin 文档

git - gist.github.com 是否有在防火墙后运行的内部替代方案?

javascript - 如何使用 GraalVM 创建 node.js 原生镜像

javascript - 将对象传递给 sails.js 中的views/layout.ejs

javascript - 使用 Node 代理时出错

c# webClient.DownloadFile 不下载,它只是创建一个空文本文件

css - wufoo 表单不适用于我在 pastebin 中的 CSS 文件