- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在指定一个 ReST 服务。我最近偶然发现了这个 IETF draft document这可以解释为建议 ReST 服务应始终返回 308。请注意,该文档似乎已过期而未被取代(我对 IETF 流程不是很清楚)。
我早些时候想到,服务应该为 GET 返回“301 Moved Permanently”,为 POST 返回“308 Permanent Redirect”,以确保它不会不恰本地转换为 GET(通过某些试图变得聪明的东西).
301 和 308 的使用似乎是用“应该”和“不应该”来表达的,而不是“必须”和“不能”,因此从哲学上讲,“正确的事情”是什么还不清楚。
GET 的 301 和 POST 的 308 应该有效。GET 的 308 没有错误,因为 current revision在撰写本文时,包含响应 GET 生成 308 的示例。现在有一个部署问题,如果客户端不理解 308,它应该将其视为 300(而不是 301,这对我来说更有意义),但 308 现在已被广泛理解,所以问题变成了你是否或为什么应该使用 HTTP 301?
如果 308 本质上是 301 的错误修复,为什么 301 没有在 HTTP/1.1 中正式弃用?是否存在将 POST 转换为 GET 以在 ReST 或更普遍的 HTTP 中重定向的合法用例?
对于 301 HTTP/1.1 说:
Note: For historical reasons, a user agent MAY change the requestmethod from POST to GET for the subsequent request.
为什么这是个好主意?它在任何地方仍然有效吗?
另见:
最佳答案
If
308
is essentially a bug fix for301
, why isn't301
officially deprecated in HTTP/1.1?
不,不是。
RFC 7538 ,它定义了 308
状态代码,不会使 301
失效或过时。它只是定义另一个 状态代码来填补 RFC 7231 上的空白,它没有定义永久状态码 307
的变体:
+-------------------------------------------+-----------+-----------+
| | Permanent | Temporary |
+-------------------------------------------+-----------+-----------+
| Allows changing the request method from | 301 | 302 |
| POST to GET | | |
| Does not allow changing the request | - | 307 |
| method from POST to GET | | |
+-------------------------------------------+-----------+-----------+
实际上,我仍然看到 301
主要用于 SEO。我还看到一些 HTTP 客户端无法识别 308
。
除了RFC,让我们看看Mozilla 的MDN Web 文档say关于301
:
The HyperText Transfer Protocol (HTTP)
301 Moved Permanently
redirect status response code indicates that the resource requested has been definitively moved to the URL given by the Location headers. A browser redirects to this page and search engines update their links to the resource (in 'SEO-speak', it is said that the 'link-juice' is sent to the new URL).Even if the specification requires the method (and the body) not to be altered when the redirection is performed, not all user-agents align with it - you can still find this type of bugged software out there. It is therefore recommended to use the
301
code only as a response forGET
orHEAD
methods and to use the308 Permanent Redirect
forPOST
methods instead, as the method change is explicitly prohibited with this status.
现在看看Mozilla says关于308
:
The HyperText Transfer Protocol (HTTP)
308 Permanent Redirect
redirect status response code indicates that the resource requested has been definitively moved to the URL given by theLocation
headers. A browser redirects to this page and search engines update their links to the resource (in 'SEO-speak', it is said that the 'link-juice' is sent to the new URL).The request method and the body will not be altered, whereas
301
may incorrectly sometimes be changed to aGET
method.Note: Some Web applications may use the
308 Permanent Redirect
in a non-standard way and for other purposes. For example, Google Drive uses a308 Resume Incomplete
response to indicate to the client when an incomplete upload stalled. (reference)
关于rest - 是否仍然有 HTTP 301 而不是 HTTP 308 的用例来指示资源已移动(特别是在 ReST 服务器中)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53436107/
我正在尝试复兴使用3DNow的旧Win32游戏!指令集以进行3D渲染。 在Win7-Win10等现代OS上,不允许FPADD或FPMUL之类的Win10指令,并且该程序将引发异常。 自3DNow数量!
我坐在机场这里,想出了一些我想尝试的东西,但如果 macports 下载-编译-下载-编译,我没有时间 sudo port install .但是,如果它下载了所有内容,那么我就可以在飞机上对其进行编
我使用的是 Jackson 库,而不是 2.6.3。我想在类中定义序列化方法,并且我想指示 Jackson 在序列化对象时调用此方法。 例如 public interface AClass { d
我正在制作一个自动目录,一切正常。我只需要将顶部标题指定为“粗体” jQuery(document).ready(function(){ var ToC = "" + ""; var ne
我要设置 html 对象的属性。 var property1 = 'style.visibility'; var property2 = 'style.display'; var property3
在 boost::spirit::traits::transform_attribute 中指示解析失败的正确方法是什么?我可以抛出任何旧的异常,还是它要我做的特定事情? namespace boos
我正在使用 XmlPullParser 在移动设备上通过 http 逐渐加载一些数据。 由于此类连接的速度通常可以低至 1KB/s 或更低,我想降低 PullParser 的默认缓冲区大小 8096
我正在尝试集体检查数据是否存在于各个表中。我有一个主表 A 和包含与 A 相关的数据的各种表 - 称它们为表 B、C 和 D。我想编写一个查询,对于 A 中的每个条目,指示是否有任何行在 B、C 和
当您使用 Cargo 和 rustdoc 为 Rust crate 生成文档时,我在生成的页面中看不到任何指示它适用于哪个版本的 crate。例如,看看 the log crate's documen
我有一个 CS 类,它表示 3D 坐标系,即 (x, y, z) class CS { private: double x; double y; d
我有一个用 Wordpress 制作的项目。我有在社交网络上分享的帖子。在推特上没有问题,因为我创建的推文没有图片。Facebook 允许我从要分享的链接中选择页面图像。但是 Google+ 正在挑选
问题 如何在 Scrapy 中忽略响应的内容长度? 解释 考虑这个 curl 命令" curl -u http://data.icecat.biz/export/level4/NL/files.in
我有一个测试程序,如果它可以依赖于在 Windows 上以严格的优先级顺序安排的线程,它会简单得多。我看到一个低优先级线程与高优先级线程一起运行,我想知道这是不是因为不同的线程被安排在不同的处理器内核
我正在使用 getUserMedia 函数从网络摄像头录制视频。一切正常,除了它仅以 640x480 分辨率录制,当我刚刚指定 video: true 作为约束时。 如果我按如下方式设置约束,我现在可
我有一个简单的类定义如下: class Model { constructor(props?:{}) { _extend(props, this); } } 其中构造函数接受一个对象作
我第一次在 Visual Studio 2010 beta 2 中使用 .net-4.0 中的 System.ComponentModel.Composition 试用托管扩展框架。 我一直无法让 C
我正在使用 System.CodeDom 功能在运行时编译代码,我想知道我是否可以指定一个编译器参数或其他解决方法来以英语语言显示编译器错误,而不是使用系统的默认语言语言。 但是,在 MSDN 文档中
我正在使用 XmlWriterSettings 将 Xml 写入文件。我有只有属性的元素,没有 child 。我希望它们输出为: 代替 我可以使用 XmlWriterSettings 来实现吗?
我在 sbt 中创建了一个多项目构建。这是 build.sbt 在主目录中: lazy val root = project in file(".") aggregate(data, reco, re
这里我有一个程序,可以计算一个人不同的日常事件,例如他一周踢足球的次数等。这里我有一个 switch 语句,可以计算不同事件的值。我强制这个对象指示 sort() 函数内的 dayEvents 对象。
我是一名优秀的程序员,十分优秀!