mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-15 11:30:11 +01:00
Set the correct response status on internal redirects
This commit is contained in:
parent
8b4980b4ca
commit
9334a09176
@ -286,14 +286,14 @@ bool CefResourceRequestJob::IsRedirectResponse(GURL* location,
|
||||
int* http_status_code) {
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
bool redirect = false;
|
||||
|
||||
if (redirect_url_.is_valid()) {
|
||||
// Redirect to the new URL.
|
||||
*http_status_code = 303;
|
||||
location->Swap(&redirect_url_);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (response_.get()) {
|
||||
redirect = true;
|
||||
} else if (response_.get()) {
|
||||
// Check for HTTP 302 or HTTP 303 redirect.
|
||||
int status = response_->GetStatus();
|
||||
if (status == 302 || status == 303) {
|
||||
@ -304,12 +304,20 @@ bool CefResourceRequestJob::IsRedirectResponse(GURL* location,
|
||||
GURL new_url = GURL(std::string(iter->second));
|
||||
*http_status_code = status;
|
||||
location->Swap(&new_url);
|
||||
return true;
|
||||
redirect = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
if (redirect) {
|
||||
// Set the correct response status. This avoids a DCHECK in
|
||||
// RedirectInfo::ComputeRedirectInfo.
|
||||
request_->response_headers()->ReplaceStatusLine(
|
||||
*http_status_code == 302 ? "HTTP/1.1 302 Found"
|
||||
: "HTTP/1.1 303 See Other");
|
||||
}
|
||||
|
||||
return redirect;
|
||||
}
|
||||
|
||||
bool CefResourceRequestJob::GetMimeType(std::string* mime_type) const {
|
||||
|
@ -939,8 +939,9 @@ class RedirectTestHandler : public TestHandler {
|
||||
// Called due to the nav3 redirect response.
|
||||
got_nav3_redirect_.yes();
|
||||
|
||||
EXPECT_EQ(200, response->GetStatus());
|
||||
EXPECT_TRUE(response->GetStatusText().empty());
|
||||
EXPECT_EQ(303, response->GetStatus());
|
||||
EXPECT_STREQ("See Other",
|
||||
response->GetStatusText().ToString().c_str());
|
||||
EXPECT_STREQ("text/html", response->GetMimeType().ToString().c_str());
|
||||
} else {
|
||||
got_invalid_redirect_.yes();
|
||||
|
Loading…
x
Reference in New Issue
Block a user