Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: Source/modules/fetch/Request.cpp

Issue 1143083002: Implement request's redirect mode and RequestRedirect for Fetch (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/fetch/Request.cpp
diff --git a/Source/modules/fetch/Request.cpp b/Source/modules/fetch/Request.cpp
index 44339b9bf18cfee062b936c06de1fdc2243b4828..d8a7c9d71304c049edda0c50c42099e899f5a524 100644
--- a/Source/modules/fetch/Request.cpp
+++ b/Source/modules/fetch/Request.cpp
@@ -35,8 +35,8 @@ FetchRequestData* createCopyOfFetchRequestDataForFetch(ExecutionContext* context
request->mutableReferrer()->setClient();
request->setMode(original->mode());
request->setCredentials(original->credentials());
+ request->setRedirect(original->redirect());
// FIXME: Set cache mode.
- // TODO(yhirano): Set redirect mode.
return request;
}
@@ -140,14 +140,30 @@ Request* Request::createRequestWithRequestOrString(ExecutionContext* context, Re
// |fallbackCache| otherwise."
// FIXME: "15. If |cache| is non-null, set |request|'s cache mode to
// |cache|."
+
// TODO(yhirano): "16. If |init|'s redirect member is present and its is
yhirano 2015/05/25 06:30:52 Please delete this TODO as you implement it.
shiva.jm 2015/05/25 12:01:57 Done.
// manual, throw a TypeError."
+ if (init.redirect == "manual") {
+ exceptionState.throwTypeError("'" + init.redirect + "' manual redirect method is unsupported.");
+ return nullptr;
+ }
+
// TODO(yhirano): "17. Let |redirect| be |init|'s redirect member if it is
yhirano 2015/05/25 06:30:53 ditto
shiva.jm 2015/05/25 12:01:57 Done.
// present, and |fallbackRedirect| otherwise."
// TODO(yhirano): "18 If |redirect| is non-null, set |request|'s redirect
yhirano 2015/05/25 06:30:52 ditto
shiva.jm 2015/05/25 12:01:57 Done.
// mode to |redirect|."
// TODO(yhirano): "19 If |request|'s redirect mode is manual, set it to
yhirano 2015/05/25 06:30:52 ditto
shiva.jm 2015/05/25 12:01:57 Done.
// follow."
+ if (init.redirect == "follow") {
+ request->setRedirect(WebURLRequest::FetchRedirectModeFollow);
+ } else if (init.redirect == "manual") {
+ request->setRedirect(WebURLRequest::FetchRedirectModeFollow);
+ } else if (init.redirect == "error") {
+ request->setRedirect(WebURLRequest::FetchRedirectModeError);
+ } else {
+ if (!inputRequest)
+ request->setRedirect(WebURLRequest::FetchRedirectModeFollow);
+ }
// "20. If |init|'s method member is present, let |method| be it and run
// these substeps:"
@@ -450,6 +466,21 @@ String Request::credentials() const
return "";
}
+String Request::redirect() const
+{
+ // "The redirect attribute's getter must return request's redirect mode."
+ switch (m_request->redirect()) {
+ case WebURLRequest::FetchRedirectModeFollow:
+ return "follow";
+ case WebURLRequest::FetchRedirectModeError:
+ return "error";
+ case WebURLRequest::FetchRedirectModeManual:
+ return "manual";
+ }
+ ASSERT_NOT_REACHED();
+ return "";
+}
+
Request* Request::clone(ExceptionState& exceptionState) const
{
if (bodyUsed()) {
@@ -487,6 +518,7 @@ void Request::populateWebServiceWorkerRequest(WebServiceWorkerRequest& webReques
{
webRequest.setMethod(method());
webRequest.setRequestContext(m_request->context());
+ webRequest.setRedirectMode(m_request->redirect());
// This strips off the fragment part.
webRequest.setURL(url());

Powered by Google App Engine
This is Rietveld 408576698