fetch_event.js revision cedac228d2dd51db4b79ea1e72c7f249408ee061
1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)this.onfetch = function(event) { 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) var headers = new HeaderMap; 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) headers.set('Content-Language', 'fi'); 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) headers.set('Content-Type', 'text/html; charset=UTF-8'); 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) var response = new Response({ 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) status: 301, 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) statusText: 'Moved Permanently', 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) headers: headers 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) }); 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) event.respondWith(new Promise(function(r) { 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) setTimeout(function() { r(response); }, 5); 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) })); 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 19