HTTP:发布请求收到302,重定向重新要求是一个吗?

问题描述 投票:0回答:2
RFC2616,第10.3节3xx

第3xx,但我并没有真正从那里得到什么请求类型,在何种情况下,redirect-requequest应该具有什么,即函数(初始request-type,wenders-type,wenters-type) - > redirect-requect-request-request-type.

在我的特殊情况下,我有:

Initial请求类型:post
    response-type:302
  • GoogleChrome使用了重定向请求的Get。
  • 在python库
reququests

,有以下代码(

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 I.E。,在303(

codes.see_other
)的情况下,重定向 - 重复类型是在所有其他情况下获得的,它是初始请求类型。即,对于上面的我的特定情况,它将是帖子,与Chrome相反。
这可能是错误的,因为我有一个网站,这实际上似乎无法正常工作(即,网站的行为不好)。

正确的方法/功能是什么?

	

我刚刚搜索了Chrome中的相关代码,并且是:

std::string ComputeMethodForRedirect(const std::string& method, int http_status_code) { // For 303 redirects, all request methods except HEAD are converted to GET, // as per the latest httpbis draft. The draft also allows POST requests to // be converted to GETs when following 301/302 redirects, for historical // reasons. Most major browsers do this and so shall we. Both RFC 2616 and // the httpbis draft say to prompt the user to confirm the generation of new // requests, other than GET and HEAD requests, but IE omits these prompts and // so shall we. // See: // https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-17#section-7.3 if ((http_status_code == 303 && method != "HEAD") || ((http_status_code == 301 || http_status_code == 302) && method == "POST")) { return "GET"; } return method; }

http post http-redirect get http-status-code-302
2个回答
24
投票
请参阅历史记录。

在303和307中,根据

Spec
,这两种行为都是可接受的,主要是出于历史原因。
    

7
投票
我考虑了这个问题的答案是什么是在与铬和节点重新征用的情况下经历后的答案,并最初假设这是完全正常的。然后,我认为虽然它可能是“历史”,但它可能不是“正确的”。因此,我找到了此页面,听起来“正确”比与“历史”实现兼容……一分钟听起来令人失望。 然后我记得,我见过的每个“传统”,非Ajax/api,基于表格的“帖子”都以重定向的方式做出了响应。 它就是它的本质,这可能永远不会改变。感谢所有以前的响应者提供了所有相关信息。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.