gpt4 book ai didi

java - 创建 RESTEasy 端点时如何限制大体请求?

转载 作者:行者123 更新时间:2023-11-30 08:28:24 24 4
gpt4 key购买 nike

我正在创建 RESTEasy 端点,我的请求应该是非常小的 JSON 格式,例如

    {"id":"A1S2D3F4G5H6J7"}

RESTEasy 中有没有办法限制客户端发送的信息量?我想阻止客户端发送 1GB 数据并关闭我的服务。有什么想法吗?

最佳答案

这最好由网络服务器或应用服务器处理,而不是直接由您的应用程序代码处理。例如,假设您的应用程序服务器位于 Apache 后面。 Apache 通过 AJP 将请求代理到应用程序服务器。然后你可以设置 Apache 的 LimitRequestBody配置属性设置为小于 1GB 的合理值,并防止这些大请求进入您的应用程序。

来自 Apache 文档:

The LimitRequestBody directive allows the user to set a limit on the allowed size of an HTTP request message body within the context in which the directive is given (server, per-directory, per-file or per-location). If the client request exceeds that limit, the server will return an error response instead of servicing the request.

我假设所有其他主要网络服务器和应用程序容器都有配置设置来处理这种情况。

关于java - 创建 RESTEasy 端点时如何限制大体请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20207786/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com