Alb*_*ert 16 post redirect get http http-status-code-302
我正在读这个,但我并没有从那里得到重定向请求应该具有的请求类型,在什么情况下,即函数(初始请求类型,响应类型) - > redirect-request-type.
在我的特定情况下,我有:
谷歌浏览器使用GET进行重定向请求.
# 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
Run Code Online (Sandbox Code Playgroud)
即,在303(codes.see_other
)的情况下,redirect-request-type是GET ,在所有其他情况下,它是初始请求类型.即,就我上面的特定情况而言,与Chrome相比,它将是POST.
这可能是错误的,因为我有一个网站,这实际上似乎没有正确的工作(即网站这种方式表现不佳).
什么是正确的方式/功能?
Alb*_*ert 20
我只是搜索在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;
}
Run Code Online (Sandbox Code Playgroud)
根据RFC 2616,答案是"原始方法".HTTPbis会对此进行修改,因为它不能反映浏览器的功能(遗憾的是).
有关历史,请参见http://trac.tools.ietf.org/wg/httpbis/trac/ticket/160.
归档时间: |
|
查看次数: |
22642 次 |
最近记录: |