Commit 2d1195b3 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

HTTPS Previews: Move up the early return in WillProcessResponse

I got a crash earlier today where WillProcessResponse was being called
on a non-preview page without response headers, so the DCHECK failed.

Moving up the early return makes the navigation throttle more robust
against this in the future.

Bug: 864635
Change-Id: Ief8e3b2b0ac9179d2ba16ff8f04c950b08f9564d
Reviewed-on: https://chromium-review.googlesource.com/c/1265059
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597182}
parent a6cb108d
...@@ -412,16 +412,15 @@ PreviewsLitePageNavigationThrottle::WillFailRequest() { ...@@ -412,16 +412,15 @@ PreviewsLitePageNavigationThrottle::WillFailRequest() {
content::NavigationThrottle::ThrottleCheckResult content::NavigationThrottle::ThrottleCheckResult
PreviewsLitePageNavigationThrottle::WillProcessResponse() { PreviewsLitePageNavigationThrottle::WillProcessResponse() {
const net::HttpResponseHeaders* response_headers =
navigation_handle()->GetResponseHeaders();
DCHECK(response_headers);
std::string original_url; std::string original_url;
if (!GetOriginalURL(navigation_handle()->GetURL(), &original_url)) { if (!GetOriginalURL(navigation_handle()->GetURL(), &original_url)) {
// Return early if this request was not for a Preview. // Return early if this request was not for a Preview.
return content::NavigationThrottle::PROCEED; return content::NavigationThrottle::PROCEED;
} }
const net::HttpResponseHeaders* response_headers =
navigation_handle()->GetResponseHeaders();
// After this point, the given response is known to be for a Preview. // After this point, the given response is known to be for a Preview.
// The Previews server will only send the following response codes: 200, 307, // The Previews server will only send the following response codes: 200, 307,
// 404, and 503. 200 and 307 should proceed as normal, 404 and 503 request the // 404, and 503. 200 and 307 should proceed as normal, 404 and 503 request the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment