Type Header and Derive Type from URL

I have a question regarding a REST API's HTTP compliance. Is it ever advisable to override / ignore the "Content-Type" header in a request body when designing a REST API interface and instead derive the type of content from information provided in the URL?

For example, is there a reason to allow the following example:

POST /url.xml
Content-Type: application/x-www-form-urlencoded

<?xml version="1.0"?>
<xml>
...
</xml>

In this workflow the content-type is determined by the ".xml" extension on the URL, which is non-standard. In general it is poor practice to rely on non-standards in lieu of standards. However, some REST API clients will automatically add a default content-type if the developer does not specify one.

Is there ever a reason to break away from the standard and override the content-type in a request entity? Wouldn't this break interoperability on the web?

链接地址: http://www.djcxy.com/p/71446.html

上一篇: 在单个请求中批量创建或更新

下一篇: 从URL中输入标题和派生类型