Index: Source/modules/fetch/Response.cpp |
diff --git a/Source/modules/fetch/Response.cpp b/Source/modules/fetch/Response.cpp |
index 62cd8f2d84c6bfa1412db5e250fa097d53e8ea27..7718bd7a33d4c38304924dbdfd32b03b2d473e3c 100644 |
--- a/Source/modules/fetch/Response.cpp |
+++ b/Source/modules/fetch/Response.cpp |
@@ -242,6 +242,28 @@ Response* Response::error(ExecutionContext* context) |
return r; |
} |
+Response* Response::redirect(ExecutionContext* context, const String& url, unsigned short status, ExceptionState& exceptionState) |
+{ |
+ KURL parsedURL = context->completeURL(url); |
+ if (!parsedURL.isValid()) { |
+ exceptionState.throwTypeError("Failed to parse URL from " + url); |
+ return nullptr; |
+ } |
+ |
+ if (status !=301 && status !=302 && status !=303 && status !=307 && status !=308) { |
tyoshino (SeeGerritForStatus)
2015/04/20 04:31:44
put a space between != and the second operand
horo
2015/04/20 04:32:12
spaces after "!="
if (status != 301 && status !=
shiva.jm
2015/04/27 10:50:55
Done.
shiva.jm
2015/04/27 10:50:55
Done.
|
+ exceptionState.throwRangeError("Invalid statusCode"); |
tyoshino (SeeGerritForStatus)
2015/04/20 04:50:00
statusCode -> status, since the argument name in t
shiva.jm
2015/04/27 10:50:55
Done. changed to "status code"
|
+ return nullptr; |
+ } |
+ |
+ Response* r = new Response(context); |
+ r->m_headers->setGuard(Headers::ImmutableGuard); |
+ r->suspendIfNeeded(); |
yhirano
2015/04/20 04:55:30
Please call |suspendIfNeeded| right after creation
shiva.jm
2015/04/27 10:50:55
Done.
|
+ r->m_response->setStatus(status); |
+ r->m_response->headerList()->set("Location", parsedURL); |
+ |
+ return r; |
+} |
+ |
String Response::type() const |
{ |
// "The type attribute's getter must return response's type." |