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

Side by Side Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 576973004: Make ServiceWorkerFetchRequest and ServiceWorkerResponse header maps case insensitive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test Created 6 years, 3 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 "content/browser/service_worker/service_worker_url_request_job.h" 5 #include "content/browser/service_worker/service_worker_url_request_job.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 CreateResponseHeader( 407 CreateResponseHeader(
408 response.status_code, response.status_text, response.headers); 408 response.status_code, response.status_text, response.headers);
409 load_timing_info_.receive_headers_end = base::TimeTicks::Now(); 409 load_timing_info_.receive_headers_end = base::TimeTicks::Now();
410 if (!blob_request_) 410 if (!blob_request_)
411 CommitResponseHeader(); 411 CommitResponseHeader();
412 } 412 }
413 413
414 void ServiceWorkerURLRequestJob::CreateResponseHeader( 414 void ServiceWorkerURLRequestJob::CreateResponseHeader(
415 int status_code, 415 int status_code,
416 const std::string& status_text, 416 const std::string& status_text,
417 const std::map<std::string, std::string>& headers) { 417 const ServiceWorkerHeaderMap& headers) {
418 // TODO(kinuko): If the response has an identifier to on-disk cache entry, 418 // TODO(kinuko): If the response has an identifier to on-disk cache entry,
419 // pull response header from the disk. 419 // pull response header from the disk.
420 std::string status_line( 420 std::string status_line(
421 base::StringPrintf("HTTP/1.1 %d %s", status_code, status_text.c_str())); 421 base::StringPrintf("HTTP/1.1 %d %s", status_code, status_text.c_str()));
422 status_line.push_back('\0'); 422 status_line.push_back('\0');
423 http_response_headers_ = new net::HttpResponseHeaders(status_line); 423 http_response_headers_ = new net::HttpResponseHeaders(status_line);
424 for (std::map<std::string, std::string>::const_iterator it = headers.begin(); 424 for (ServiceWorkerHeaderMap::const_iterator it = headers.begin();
425 it != headers.end(); 425 it != headers.end();
426 ++it) { 426 ++it) {
427 std::string header; 427 std::string header;
428 header.reserve(it->first.size() + 2 + it->second.size()); 428 header.reserve(it->first.size() + 2 + it->second.size());
429 header.append(it->first); 429 header.append(it->first);
430 header.append(": "); 430 header.append(": ");
431 header.append(it->second); 431 header.append(it->second);
432 http_response_headers_->AddHeader(header); 432 http_response_headers_->AddHeader(header);
433 } 433 }
434 } 434 }
435 435
436 void ServiceWorkerURLRequestJob::CommitResponseHeader() { 436 void ServiceWorkerURLRequestJob::CommitResponseHeader() {
437 http_response_info_.reset(new net::HttpResponseInfo()); 437 http_response_info_.reset(new net::HttpResponseInfo());
438 http_response_info_->headers.swap(http_response_headers_); 438 http_response_info_->headers.swap(http_response_headers_);
439 NotifyHeadersComplete(); 439 NotifyHeadersComplete();
440 } 440 }
441 441
442 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { 442 void ServiceWorkerURLRequestJob::DeliverErrorResponse() {
443 // TODO(falken): Print an error to the console of the ServiceWorker and of 443 // TODO(falken): Print an error to the console of the ServiceWorker and of
444 // the requesting page. 444 // the requesting page.
445 CreateResponseHeader(500, 445 CreateResponseHeader(
446 "Service Worker Response Error", 446 500, "Service Worker Response Error", ServiceWorkerHeaderMap());
447 std::map<std::string, std::string>());
448 CommitResponseHeader(); 447 CommitResponseHeader();
449 } 448 }
450 449
451 } // namespace content 450 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698