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

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
« no previous file with comments | « Source/modules/fetch/Request.h ('k') | Source/modules/fetch/Request.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/fetch/Request.cpp
diff --git a/Source/modules/fetch/Request.cpp b/Source/modules/fetch/Request.cpp
index 8e26455835b151b4c93e53dd1096be81aea80c8c..4c8c02cc8fd82abf17a3ed6a64cb0495597d0bbb 100644
--- a/Source/modules/fetch/Request.cpp
+++ b/Source/modules/fetch/Request.cpp
@@ -39,8 +39,8 @@ FetchRequestData* createCopyOfFetchRequestDataForFetch(ScriptState* scriptState,
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;
}
@@ -144,14 +144,22 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
// |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
- // manual, throw a TypeError."
- // TODO(yhirano): "17. Let |redirect| be |init|'s redirect member if it is
- // present, and |fallbackRedirect| otherwise."
- // TODO(yhirano): "18 If |redirect| is non-null, set |request|'s redirect
- // mode to |redirect|."
- // TODO(yhirano): "19 If |request|'s redirect mode is manual, set it to
- // follow."
+
+ if (init.redirect == "manual") {
+ exceptionState.throwTypeError("'" + init.redirect + "' manual redirect method is unsupported.");
+ return nullptr;
+ }
+
+ 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:"
@@ -454,6 +462,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()) {
@@ -491,6 +514,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());
« no previous file with comments | « Source/modules/fetch/Request.h ('k') | Source/modules/fetch/Request.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698