HTTP:POST 请求收到 302,重定向请求是否应该是 GET? [英] HTTP: POST request receives a 302, should the redirect-request be a GET?
问题描述
我正在阅读这个,但我并没有真正从那里得到什么情况下redirect-request应该有什么request-type,即函数(初始请求类型,响应类型)->redirect-request-type.
I was reading this but I didn't really got from there what request-type the redirect-request should have in what case, i.e. the function (initial request-type, response-type) -> redirect-request-type.
在我的特殊情况下,我有:
In my particular case, I had:
- 初始请求类型:POST
- 响应类型:302
谷歌浏览器对重定向的请求使用了 GET.
Google Chrome used a GET for the redirected request.
In the Python library requests, there is the following code (here):
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
if r.status_code is codes.see_other:
method = 'GET'
else:
method = self.method
即,在 303 (codes.see_other
) 的情况下,重定向请求类型是 GET,在所有其他情况下,它是初始请求类型.即,对于我上面的特殊情况,与 Chrome 相比,它将是 POST.
I.e., the redirect-request-type is GET in case of 303 (codes.see_other
), in all other cases it is the initial request-type. I.e., for my particular case above, it would be POST, in contrast to Chrome.
这可能是错误的,因为我有一个网站实际上似乎无法正常工作(即该网站在这种情况下表现不佳).
This is probably wrong because I have one website where this actually doesn't seem to work correct (i.e. the website doesn't behave well this way).
正确的方式/功能是什么?
What would be the correct way/function?
推荐答案
根据 RFC 2616,答案是原始方法".HTTPbis 将对此进行修改,因为它没有反映浏览器的功能(遗憾的是).
Per RFC 2616, the answer is "the original method". HTTPbis will revise this, as it doesn't reflect what browsers do (sadly).
参见 http://trac.tools.ietf.org/wg/httpbis/trac/门票/160 用于历史记录.
See http://trac.tools.ietf.org/wg/httpbis/trac/ticket/160 for the history.
这篇关于HTTP:POST 请求收到 302,重定向请求是否应该是 GET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!