Initial请求类型:post
,有以下代码(
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;
}