【问题标题】:nodejs / expressjs sends empty response on large requestURInodejs / expressjs 在大型 requestURI 上发送空响应
【发布时间】:2018-12-05 21:22:20
【问题描述】:

我正在尝试在 express.js 中处理带有大参数的 GET 请求。 我正在使用 express 4.14.0 的 docker 容器中运行节点 8 'carbon'。

requestURI 总共有 9971 个字节。

例如http://somedomain.com/path?param1=dfsgbdg&param2=verrylargeparam

卷曲响应: curl: (52) 来自服务器的空回复

如果我将大小减小到 8k 以下,一切都很好。

node 或 express 是否存在可以解释这种行为的硬性限制? 我可以提高限额吗? (不是正文,requestURI) 我需要切换到 POST 吗?

提前致谢

c

这是我的流派设置

let router = express();

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 10000000000}));

router.use(compression());

router.use(function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'X-Requested-With');
    res.header('Access-Control-Allow-Headers', 'Content-type');
    res.header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
    next();
});


router.get('/my/get/route', myExecFunction);
router.use(another);
router.use(another);
router.use(another);
router.use(another);
router.use(another);
router.use(another);
router.use(another);
router.use(another);
router.use(another);


router.enable('trust proxy');

router.listen(process.env.HTTP_PORT);
logger.info(`Running on http://localhost:${process.env.HTTP_PORT}`);

export default router;

【问题讨论】:

    标签: node.js express get


    【解决方案1】:

    请求的标头 + URI 不应超过 80 kb。 此外,如果您要从浏览器访问此 url,则大多数浏览器都会施加 2083 个字符的限制;如果您要添加更多参数,这可能会成为以后的瓶颈。

    我认为将其转换为 post 方法应该是一个不错的选择

    【讨论】:

      猜你喜欢
      • 2019-07-12
      • 2013-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-31
      • 2018-09-16
      • 2017-04-10
      • 2022-01-25
      相关资源
      最近更新 更多