Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/httpd.js

Issue 6309214725079040: Issue 1409 - Fix some errors in adblockplustest (Closed)
Patch Set: Created Sept. 19, 2014, 10:35 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/tests/filterStorage.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et: */ 2 /* vim:set ts=2 sw=2 sts=2 et: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public 3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 6
7 /* 7 /*
8 * An implementation of an HTTP server both as a loadable script and as an XPCOM 8 * An implementation of an HTTP server both as a loadable script and as an XPCOM
9 * component. See the accompanying README file for user documentation on 9 * component. See the accompanying README file for user documentation on
10 * httpd.js. 10 * httpd.js.
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 }, 698 },
699 699
700 700
701 // NSISUPPORTS 701 // NSISUPPORTS
702 702
703 // 703 //
704 // see nsISupports.QueryInterface 704 // see nsISupports.QueryInterface
705 // 705 //
706 QueryInterface: function(iid) 706 QueryInterface: function(iid)
707 { 707 {
708 if (iid.equals(Ci.nsIHttpServer) || 708 if (iid.equals(Ci.nsIServerSocketListener) || iid.equals(Ci.nsISupports))
709 iid.equals(Ci.nsIServerSocketListener) ||
710 iid.equals(Ci.nsISupports))
711 return this; 709 return this;
712 710
713 throw Cr.NS_ERROR_NO_INTERFACE; 711 throw Cr.NS_ERROR_NO_INTERFACE;
714 }, 712 },
715 713
716 714
717 // NON-XPCOM PUBLIC API 715 // NON-XPCOM PUBLIC API
718 716
719 /** 717 /**
720 * Returns true iff this server is not running (and is not in the process of 718 * Returns true iff this server is not running (and is not in the process of
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 if (name.charAt(name.length - 1) == HIDDEN_CHAR) 2129 if (name.charAt(name.length - 1) == HIDDEN_CHAR)
2132 name = name.substring(0, name.length - 1); 2130 name = name.substring(0, name.length - 1);
2133 2131
2134 var headerFile = file.parent; 2132 var headerFile = file.parent;
2135 headerFile.append(name + HEADERS_SUFFIX); 2133 headerFile.append(name + HEADERS_SUFFIX);
2136 2134
2137 if (!headerFile.exists()) 2135 if (!headerFile.exists())
2138 return; 2136 return;
2139 2137
2140 const PR_RDONLY = 0x01; 2138 const PR_RDONLY = 0x01;
2141 var fis = new FileInputStream(headerFile, PR_RDONLY, 0444, 2139 var fis = new FileInputStream(headerFile, PR_RDONLY, 0o444,
2142 Ci.nsIFileInputStream.CLOSE_ON_EOF); 2140 Ci.nsIFileInputStream.CLOSE_ON_EOF);
2143 2141
2144 try 2142 try
2145 { 2143 {
2146 var lis = new ConverterInputStream(fis, "UTF-8", 1024, 0x0); 2144 var lis = new ConverterInputStream(fis, "UTF-8", 1024, 0x0);
2147 lis.QueryInterface(Ci.nsIUnicharLineInputStream); 2145 lis.QueryInterface(Ci.nsIUnicharLineInputStream);
2148 2146
2149 var line = {value: ""}; 2147 var line = {value: ""};
2150 var more = lis.readLine(line); 2148 var more = lis.readLine(line);
2151 2149
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 * @param count: uint 2664 * @param count: uint
2667 * the number of bytes to write 2665 * the number of bytes to write
2668 */ 2666 */
2669 _writeFileResponse: function(metadata, file, response, offset, count) 2667 _writeFileResponse: function(metadata, file, response, offset, count)
2670 { 2668 {
2671 const PR_RDONLY = 0x01; 2669 const PR_RDONLY = 0x01;
2672 2670
2673 var type = this._getTypeFromFile(file); 2671 var type = this._getTypeFromFile(file);
2674 if (type === SJS_TYPE) 2672 if (type === SJS_TYPE)
2675 { 2673 {
2676 var fis = new FileInputStream(file, PR_RDONLY, 0444, 2674 var fis = new FileInputStream(file, PR_RDONLY, 0o444,
2677 Ci.nsIFileInputStream.CLOSE_ON_EOF); 2675 Ci.nsIFileInputStream.CLOSE_ON_EOF);
2678 2676
2679 try 2677 try
2680 { 2678 {
2681 var sis = new ScriptableInputStream(fis); 2679 var sis = new ScriptableInputStream(fis);
2682 var s = Cu.Sandbox(gGlobalObject); 2680 var s = Cu.Sandbox(gGlobalObject);
2683 s.importFunction(dump, "dump"); 2681 s.importFunction(dump, "dump");
2684 2682
2685 // Define a basic key-value state-preservation API across requests, wi th 2683 // Define a basic key-value state-preservation API across requests, wi th
2686 // keys initially corresponding to the empty string. 2684 // keys initially corresponding to the empty string.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 response.setHeader("Last-Modified", 2758 response.setHeader("Last-Modified",
2761 toDateString(file.lastModifiedTime), 2759 toDateString(file.lastModifiedTime),
2762 false); 2760 false);
2763 } 2761 }
2764 catch (e) { /* lastModifiedTime threw, ignore */ } 2762 catch (e) { /* lastModifiedTime threw, ignore */ }
2765 2763
2766 response.setHeader("Content-Type", type, false); 2764 response.setHeader("Content-Type", type, false);
2767 maybeAddHeaders(file, metadata, response); 2765 maybeAddHeaders(file, metadata, response);
2768 response.setHeader("Content-Length", "" + count, false); 2766 response.setHeader("Content-Length", "" + count, false);
2769 2767
2770 var fis = new FileInputStream(file, PR_RDONLY, 0444, 2768 var fis = new FileInputStream(file, PR_RDONLY, 0o444,
2771 Ci.nsIFileInputStream.CLOSE_ON_EOF); 2769 Ci.nsIFileInputStream.CLOSE_ON_EOF);
2772 2770
2773 offset = offset || 0; 2771 offset = offset || 0;
2774 count = count || file.fileSize; 2772 count = count || file.fileSize;
2775 NS_ASSERT(offset === 0 || offset < file.fileSize, "bad offset"); 2773 NS_ASSERT(offset === 0 || offset < file.fileSize, "bad offset");
2776 NS_ASSERT(count >= 0, "bad count"); 2774 NS_ASSERT(count >= 0, "bad count");
2777 NS_ASSERT(offset + count <= file.fileSize, "bad total data size"); 2775 NS_ASSERT(offset + count <= file.fileSize, "bad total data size");
2778 2776
2779 try 2777 try
2780 { 2778 {
(...skipping 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 5287
5290 // get rid of any pending requests 5288 // get rid of any pending requests
5291 while (thread.hasPendingEvents()) 5289 while (thread.hasPendingEvents())
5292 thread.processNextEvent(true); 5290 thread.processNextEvent(true);
5293 5291
5294 DEBUG = false; 5292 DEBUG = false;
5295 } 5293 }
5296 5294
5297 window.nsHttpServer = nsHttpServer; 5295 window.nsHttpServer = nsHttpServer;
5298 })(); 5296 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/content/tests/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld