diff options
author | Iain Merrick <husky@google.com> | 2010-10-29 12:42:54 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-10-29 15:34:19 +0100 |
commit | 46b75014d5af916d184897a7c475f8afc5db05c5 (patch) | |
tree | fe024436ff05abc2810d8bf6357863b2960e051b /WebKit/android/WebCoreSupport/WebRequest.cpp | |
parent | 87b843d1e151717b6e307b1779794244e59a122d (diff) | |
download | external_webkit-46b75014d5af916d184897a7c475f8afc5db05c5.zip external_webkit-46b75014d5af916d184897a7c475f8afc5db05c5.tar.gz external_webkit-46b75014d5af916d184897a7c475f8afc5db05c5.tar.bz2 |
Notify WebKit of redirects in the Chrome HTTP stack.
In this CL we just defer the redirect until WebKit has had a chance
to check it, and potentially cancel it.
There's a comment in the old code asking what to do if we're given
a bad request. Looks like this should never happen; it's a DCHECK in
Chrome so I've turned it into an ASSERT here.
We only follow redirects if WebKit does not modify the URL (this is
the same behaviour as Chrome).
Change-Id: I0c8b8cd61c501527a29dda5aca521a7df4a3ccef
Diffstat (limited to 'WebKit/android/WebCoreSupport/WebRequest.cpp')
-rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp index 307a007..ef09ff7 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebRequest.cpp @@ -295,20 +295,15 @@ void WebRequest::handleBrowserURL(GURL url) void WebRequest::OnReceivedRedirect(URLRequest* newRequest, const GURL& newUrl, bool* deferRedirect) { ASSERT(m_loadState < Response, "Redirect after receiving response"); + ASSERT(newRequest && newRequest->status().is_success(), "Invalid redirect"); - if (newRequest && newRequest->status().is_success()) { - OwnPtr<WebResponse> webResponse(new WebResponse(newRequest)); - webResponse->setUrl(newUrl.spec()); - m_urlLoader->maybeCallOnMainThread(NewRunnableMethod( - m_urlLoader.get(), &WebUrlLoaderClient::willSendRequest, webResponse.release())); - } else { - // why would this happen? And what to do? - } + OwnPtr<WebResponse> webResponse(new WebResponse(newRequest)); + webResponse->setUrl(newUrl.spec()); + m_urlLoader->maybeCallOnMainThread(NewRunnableMethod( + m_urlLoader.get(), &WebUrlLoaderClient::willSendRequest, webResponse.release())); - // Here we should check if the url we get back from webkit is the same - // as newUrl, but since we are on a different thread that is not - // possible. Look into later. - return; + // Defer the redirect until followDeferredRedirect() is called. + *deferRedirect = true; } // Called when we receive an authentication failure. The delegate should @@ -362,6 +357,13 @@ void WebRequest::cancelAuth() m_request->CancelAuth(); } +void WebRequest::followDeferredRedirect() +{ + ASSERT(m_loadState < Response, "Redirect after receiving response"); + + m_request->FollowDeferredRedirect(); +} + void WebRequest::startReading() { ASSERT(m_loadState == Response || m_loadState == GotData, "StartReading in state other than RESPONSE and GOTDATA"); |