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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchResponseData.cpp

Issue 2787003002: Fetch API: Stop lowercasing header names. (Closed)
Patch Set: Rebase for landing Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/FetchResponseData.h" 5 #include "modules/fetch/FetchResponseData.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "core/dom/DOMArrayBuffer.h" 8 #include "core/dom/DOMArrayBuffer.h"
9 #include "modules/fetch/BodyStreamBuffer.h" 9 #include "modules/fetch/BodyStreamBuffer.h"
10 #include "modules/fetch/FetchHeaderList.h" 10 #include "modules/fetch/FetchHeaderList.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 FetchResponseData* FetchResponseData::CreateBasicFilteredResponse() const { 77 FetchResponseData* FetchResponseData::CreateBasicFilteredResponse() const {
78 DCHECK_EQ(type_, kDefaultType); 78 DCHECK_EQ(type_, kDefaultType);
79 // "A basic filtered response is a filtered response whose type is |basic|, 79 // "A basic filtered response is a filtered response whose type is |basic|,
80 // header list excludes any headers in internal response's header list whose 80 // header list excludes any headers in internal response's header list whose
81 // name is `Set-Cookie` or `Set-Cookie2`." 81 // name is `Set-Cookie` or `Set-Cookie2`."
82 FetchResponseData* response = 82 FetchResponseData* response =
83 new FetchResponseData(kBasicType, status_, status_message_); 83 new FetchResponseData(kBasicType, status_, status_message_);
84 response->SetURLList(url_list_); 84 response->SetURLList(url_list_);
85 for (size_t i = 0; i < header_list_->size(); ++i) { 85 for (const auto& header : header_list_->List()) {
86 const FetchHeaderList::Header* header = header_list_->List()[i].get(); 86 if (FetchUtils::IsForbiddenResponseHeaderName(header.first))
87 if (FetchUtils::IsForbiddenResponseHeaderName(header->first))
88 continue; 87 continue;
89 response->header_list_->Append(header->first, header->second); 88 response->header_list_->Append(header.first, header.second);
90 } 89 }
91 response->buffer_ = buffer_; 90 response->buffer_ = buffer_;
92 response->mime_type_ = mime_type_; 91 response->mime_type_ = mime_type_;
93 response->internal_response_ = const_cast<FetchResponseData*>(this); 92 response->internal_response_ = const_cast<FetchResponseData*>(this);
94 return response; 93 return response;
95 } 94 }
96 95
97 FetchResponseData* FetchResponseData::CreateCORSFilteredResponse() const { 96 FetchResponseData* FetchResponseData::CreateCORSFilteredResponse() const {
98 DCHECK_EQ(type_, kDefaultType); 97 DCHECK_EQ(type_, kDefaultType);
99 HTTPHeaderSet access_control_expose_header_set; 98 HTTPHeaderSet access_control_expose_header_set;
(...skipping 11 matching lines...) Expand all
111 // "A CORS filtered response is a filtered response whose type is |CORS|, 110 // "A CORS filtered response is a filtered response whose type is |CORS|,
112 // header list excludes all headers in internal response's header list, 111 // header list excludes all headers in internal response's header list,
113 // except those whose name is either one of `Cache-Control`, 112 // except those whose name is either one of `Cache-Control`,
114 // `Content-Language`, `Content-Type`, `Expires`, `Last-Modified`, and 113 // `Content-Language`, `Content-Type`, `Expires`, `Last-Modified`, and
115 // `Pragma`, and except those whose name is one of the values resulting from 114 // `Pragma`, and except those whose name is one of the values resulting from
116 // parsing `Access-Control-Expose-Headers` in internal response's header 115 // parsing `Access-Control-Expose-Headers` in internal response's header
117 // list." 116 // list."
118 FetchResponseData* response = 117 FetchResponseData* response =
119 new FetchResponseData(kCORSType, status_, status_message_); 118 new FetchResponseData(kCORSType, status_, status_message_);
120 response->SetURLList(url_list_); 119 response->SetURLList(url_list_);
121 for (size_t i = 0; i < header_list_->size(); ++i) { 120 for (const auto& header : header_list_->List()) {
122 const FetchHeaderList::Header* header = header_list_->List()[i].get(); 121 const String& name = header.first;
123 const String& name = header->first;
124 const bool explicitly_exposed = exposed_headers.Contains(name); 122 const bool explicitly_exposed = exposed_headers.Contains(name);
125 if (IsOnAccessControlResponseHeaderWhitelist(name) || 123 if (IsOnAccessControlResponseHeaderWhitelist(name) ||
126 (explicitly_exposed && 124 (explicitly_exposed &&
127 !FetchUtils::IsForbiddenResponseHeaderName(name))) { 125 !FetchUtils::IsForbiddenResponseHeaderName(name))) {
128 if (explicitly_exposed) 126 if (explicitly_exposed)
129 response->cors_exposed_header_names_.insert(name); 127 response->cors_exposed_header_names_.insert(name);
130 response->header_list_->Append(name, header->second); 128 response->header_list_->Append(name, header.second);
131 } 129 }
132 } 130 }
133 response->buffer_ = buffer_; 131 response->buffer_ = buffer_;
134 response->mime_type_ = mime_type_; 132 response->mime_type_ = mime_type_;
135 response->internal_response_ = const_cast<FetchResponseData*>(this); 133 response->internal_response_ = const_cast<FetchResponseData*>(this);
136 return response; 134 return response;
137 } 135 }
138 136
139 FetchResponseData* FetchResponseData::CreateOpaqueFilteredResponse() const { 137 FetchResponseData* FetchResponseData::CreateOpaqueFilteredResponse() const {
140 DCHECK_EQ(type_, kDefaultType); 138 DCHECK_EQ(type_, kDefaultType);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return; 263 return;
266 } 264 }
267 response.SetURLList(url_list_); 265 response.SetURLList(url_list_);
268 response.SetStatus(Status()); 266 response.SetStatus(Status());
269 response.SetStatusText(StatusMessage()); 267 response.SetStatusText(StatusMessage());
270 response.SetResponseType(FetchTypeToWebType(type_)); 268 response.SetResponseType(FetchTypeToWebType(type_));
271 response.SetResponseTime(ResponseTime()); 269 response.SetResponseTime(ResponseTime());
272 response.SetCacheStorageCacheName(CacheStorageCacheName()); 270 response.SetCacheStorageCacheName(CacheStorageCacheName());
273 response.SetCorsExposedHeaderNames( 271 response.SetCorsExposedHeaderNames(
274 HeaderSetToWebVector(cors_exposed_header_names_)); 272 HeaderSetToWebVector(cors_exposed_header_names_));
275 for (size_t i = 0; i < HeaderList()->size(); ++i) { 273 for (const auto& header : HeaderList()->List()) {
276 const FetchHeaderList::Header* header = HeaderList()->List()[i].get(); 274 response.AppendHeader(header.first, header.second);
277 response.AppendHeader(header->first, header->second);
278 } 275 }
279 } 276 }
280 277
281 FetchResponseData::FetchResponseData(Type type, 278 FetchResponseData::FetchResponseData(Type type,
282 unsigned short status, 279 unsigned short status,
283 AtomicString status_message) 280 AtomicString status_message)
284 : type_(type), 281 : type_(type),
285 status_(status), 282 status_(status),
286 status_message_(status_message), 283 status_message_(status_message),
287 header_list_(FetchHeaderList::Create()), 284 header_list_(FetchHeaderList::Create()),
(...skipping 10 matching lines...) Expand all
298 } 295 }
299 } 296 }
300 297
301 DEFINE_TRACE(FetchResponseData) { 298 DEFINE_TRACE(FetchResponseData) {
302 visitor->Trace(header_list_); 299 visitor->Trace(header_list_);
303 visitor->Trace(internal_response_); 300 visitor->Trace(internal_response_);
304 visitor->Trace(buffer_); 301 visitor->Trace(buffer_);
305 } 302 }
306 303
307 } // namespace blink 304 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchManager.cpp ('k') | third_party/WebKit/Source/modules/fetch/Headers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698