使用不适合 URL 的数据执行幂等 HTTP 请求的方法是什么?

发布于 2024-09-09 07:19:30 字数 322 浏览 2 评论 0原文

因此,基本上 URL 的 255 个字符限制对我来说太短了,我不想依赖于忽略它。

我的请求不会改变 HTTP 服务器端的任何内容。我需要发送一些带有请求的数据,该数据的大小略大于 1024 个字符,并且不具有安全/秘密字符。服务器将使用该数据对数据库进行验证并返回该验证的结果,但没有任何改变。因此,该请求被称为幂等的。在伪代码中,客户端调用 RPC:

int verify_data(char[>1024] data)

我可以使用 POST 还是这会违反 REST 和其他良好的 HTTP 客户端/服务器设计的原则?我显然不能使用GET?

So, basically the 255-char limitation of URLs is too short for me, and I don't want to rely on ignoring it.

My request will not change anything on the HTTP server end. I need to send some data with request, that is slightly larger than 1024 characters in size and is NOT of secure/secret character. The server will use the data for verification against a database and return a result of this verification, but nothing is changed. The request is thus said to be idempotent. In pseudecode, client calls RPC:

int verify_data(char[>1024] data)

Can I use POST or will this violate principles of REST and other good HTTP client/server design? I obviously cannot use GET?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月竹挽风 2024-09-16 07:19:30

我也有类似的麻烦,

可能使用 PUT 是更好的选择。我的意思是,根据 REST 原则,PUT 也应该是幂等操作(以便服务器可以缓存它)并且您没有 GET 的大小限制

I have a similar trouble

May be using PUT is a better alternative. I mean, according to REST principles PUT should also be an idempotent operation (so that servers might cache it) and you don't have the limitation size of GET

┾廆蒐ゝ 2024-09-16 07:19:30

不同浏览器中 URL 的最大长度是多少?

你控制服务器和客户端吗?如果你知道两者都能处理这个长度,那么我会继续运行它。

What is the maximum length of a URL in different browsers?

Do you control the server and the client? If you know that both will handle the length, then I would go ahead and run with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文