gpt4 book ai didi

rest - HTTP 状态 201 已创建 : Return N URLs to the new resources?

转载 作者:可可西里 更新时间:2023-11-01 15:19:33 25 4
gpt4 key购买 nike

我有一个简单的服务器 API:

客户端可以上传文件。如果成功,服务器返回 201 Created。 http 响应有一个 Location header ,它指向新创建的资源。

现在我们面临一个新的用例:一个 http 请求应该能够创建 N 个新资源。

我不确定如何根据 http 规范实现它。

据我所知,大多数情况下只有一个 Location header 。

如何在 http 201 Created 响应中返回 N 个 URL?

我的问题是相关的,但不是以下问题的重复,因为那里的问题明确回答“否”。我的问题是不同的:如何......

我的问题不是“是否允许返回多个位置 header ?”。

Can the Location header be used for multiple resource locations in a 201 Created response?

最佳答案

你可以看看rfc4918 ,它提出了一种新型响应,207(多状态),从REST & WOA Wiki复制的简短描述:

A Multi-Status response conveys information about multiple resources in situations where multiple status codes might be appropriate. The default Multi-Status response body is a text/xml or application/xml HTTP entity with a 'multistatus' root element. Further elements contain 200, 300, 400, and 500 series status codes generated during the method invocation. 100 series status codes SHOULD NOT be recorded in a 'response' XML element.

关于rest - HTTP 状态 201 已创建 : Return N URLs to the new resources?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47864802/

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