Commit f531aaf8 authored by Dong-hee Na's avatar Dong-hee Na Committed by Commit Bot

Fetch: Set the response message be an empty string

Update FetchResponseData::Create() to set the
response message to be an empty string unless
the URLs protocol is about or data or blob.

Bug: 832041
Change-Id: I9e8ec27dd8b4ba051bb97c6ca063f618191c95ce
Reviewed-on: https://chromium-review.googlesource.com/1179513Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Jinho Bang <jinho.bang@samsung.com>
Cr-Commit-Position: refs/heads/master@{#585085}
parent 7ae5f4bf
...@@ -218,6 +218,7 @@ Dominic Jodoin <dominic.jodoin@gmail.com> ...@@ -218,6 +218,7 @@ Dominic Jodoin <dominic.jodoin@gmail.com>
Dominik Röttsches <dominik.rottsches@intel.com> Dominik Röttsches <dominik.rottsches@intel.com>
Don Woodward <woodward@adobe.com> Don Woodward <woodward@adobe.com>
Donghee Na <corona10@gmail.com> Donghee Na <corona10@gmail.com>
Dong-hee Na <donghee.na92@gmail.com>
Dongie Agnir <dongie.agnir@gmail.com> Dongie Agnir <dongie.agnir@gmail.com>
Dongjun Kim <djmix.kim@samsung.com> Dongjun Kim <djmix.kim@samsung.com>
Dongseong Hwang <dongseong.hwang@intel.com> Dongseong Hwang <dongseong.hwang@intel.com>
......
This is a testharness.js-based test.
FAIL Check default redirect response assert_equals: expected "" but got "OK"
FAIL Check response returned by static method redirect(), status = 301 assert_equals: expected "" but got "OK"
FAIL Check response returned by static method redirect(), status = 302 assert_equals: expected "" but got "OK"
FAIL Check response returned by static method redirect(), status = 303 assert_equals: expected "" but got "OK"
FAIL Check response returned by static method redirect(), status = 307 assert_equals: expected "" but got "OK"
FAIL Check response returned by static method redirect(), status = 308 assert_equals: expected "" but got "OK"
PASS Check error returned when giving invalid url to redirect()
PASS Check error returned when giving invalid status to redirect(), status = 200
PASS Check error returned when giving invalid status to redirect(), status = 309
PASS Check error returned when giving invalid status to redirect(), status = 400
PASS Check error returned when giving invalid status to redirect(), status = 500
Harness: the test ran to completion.
...@@ -544,7 +544,13 @@ void FetchManager::Loader::DidReceiveResponse( ...@@ -544,7 +544,13 @@ void FetchManager::Loader::DidReceiveResponse(
new BodyStreamBuffer(script_state, sri_consumer, signal_)); new BodyStreamBuffer(script_state, sri_consumer, signal_));
} }
response_data->SetStatus(response.HttpStatusCode()); response_data->SetStatus(response.HttpStatusCode());
response_data->SetStatusMessage(response.HttpStatusText()); if (response.Url().ProtocolIsAbout() || response.Url().ProtocolIsData() ||
response.Url().ProtocolIs("blob")) {
response_data->SetStatusMessage("OK");
} else {
response_data->SetStatusMessage(response.HttpStatusText());
}
for (auto& it : response.HttpHeaderFields()) for (auto& it : response.HttpHeaderFields())
response_data->HeaderList()->Append(it.key, it.value); response_data->HeaderList()->Append(it.key, it.value);
if (response.UrlListViaServiceWorker().IsEmpty()) { if (response.UrlListViaServiceWorker().IsEmpty()) {
......
...@@ -41,15 +41,16 @@ Vector<String> HeaderSetToVector(const WebHTTPHeaderSet& headers) { ...@@ -41,15 +41,16 @@ Vector<String> HeaderSetToVector(const WebHTTPHeaderSet& headers) {
FetchResponseData* FetchResponseData::Create() { FetchResponseData* FetchResponseData::Create() {
// "Unless stated otherwise, a response's url is null, status is 200, status // "Unless stated otherwise, a response's url is null, status is 200, status
// message is `OK`, header list is an empty header list, and body is null." // message is the empty byte sequence, header list is an empty header list,
return new FetchResponseData(Type::kDefault, 200, "OK"); // and body is null."
return new FetchResponseData(Type::kDefault, 200, g_empty_atom);
} }
FetchResponseData* FetchResponseData::CreateNetworkErrorResponse() { FetchResponseData* FetchResponseData::CreateNetworkErrorResponse() {
// "A network error is a response whose status is always 0, status message // "A network error is a response whose status is always 0, status message
// is always the empty byte sequence, header list is aways an empty list, // is always the empty byte sequence, header list is aways an empty list,
// and body is always null." // and body is always null."
return new FetchResponseData(Type::kError, 0, ""); return new FetchResponseData(Type::kError, 0, g_empty_atom);
} }
FetchResponseData* FetchResponseData::CreateWithBuffer( FetchResponseData* FetchResponseData::CreateWithBuffer(
...@@ -114,7 +115,8 @@ FetchResponseData* FetchResponseData::CreateOpaqueFilteredResponse() const { ...@@ -114,7 +115,8 @@ FetchResponseData* FetchResponseData::CreateOpaqueFilteredResponse() const {
// cache state is 'none'." // cache state is 'none'."
// //
// https://fetch.spec.whatwg.org/#concept-filtered-response-opaque // https://fetch.spec.whatwg.org/#concept-filtered-response-opaque
FetchResponseData* response = new FetchResponseData(Type::kOpaque, 0, ""); FetchResponseData* response =
new FetchResponseData(Type::kOpaque, 0, g_empty_atom);
response->internal_response_ = const_cast<FetchResponseData*>(this); response->internal_response_ = const_cast<FetchResponseData*>(this);
return response; return response;
} }
...@@ -128,7 +130,7 @@ FetchResponseData* FetchResponseData::CreateOpaqueRedirectFilteredResponse() ...@@ -128,7 +130,7 @@ FetchResponseData* FetchResponseData::CreateOpaqueRedirectFilteredResponse()
// //
// https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect // https://fetch.spec.whatwg.org/#concept-filtered-response-opaque-redirect
FetchResponseData* response = FetchResponseData* response =
new FetchResponseData(Type::kOpaqueRedirect, 0, ""); new FetchResponseData(Type::kOpaqueRedirect, 0, g_empty_atom);
response->SetURLList(url_list_); response->SetURLList(url_list_);
response->internal_response_ = const_cast<FetchResponseData*>(this); response->internal_response_ = const_cast<FetchResponseData*>(this);
return response; return response;
......
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