Bug 623836: part 0: simplify Resource.setHeader. r=philiKON
authorRichard Newman <rnewman@mozilla.com>
Wed, 30 Mar 2011 18:28:56 -0700
changeset 67763 6b5bee7bbb01b7e9551b36a516c0f89a626ce78c
parent 67762 a04fc798eb366a354158920c910469d8bb6bae09
child 67764 7b7cb3e1360d53b4f25017aec367d40288bfbbe3
push id19427
push userpweitershausen@mozilla.com
push dateSun, 10 Apr 2011 18:54:44 +0000
treeherdermozilla-central@21ce62e6aebe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphiliKON
bugs623836
milestone2.0b13pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 623836: part 0: simplify Resource.setHeader. r=philiKON
services/sync/modules/resource.js
services/sync/tests/unit/test_resource.js
services/sync/tests/unit/test_resource_async.js
--- a/services/sync/modules/resource.js
+++ b/services/sync/modules/resource.js
@@ -166,22 +166,18 @@ AsyncResource.prototype = {
   // Note: Header names should be all lower case, there's no explicit
   // check for duplicates due to case!
   get headers() {
     return this.authenticator.onRequest(this._headers);
   },
   set headers(value) {
     this._headers = value;
   },
-  setHeader: function Res_setHeader() {
-    if (arguments.length % 2)
-      throw "setHeader only accepts arguments in multiples of 2";
-    for (let i = 0; i < arguments.length; i += 2) {
-      this._headers[arguments[i].toLowerCase()] = arguments[i + 1];
-    }
+  setHeader: function Res_setHeader(header, value) {
+    this._headers[header.toLowerCase()] = value;
   },
 
   // ** {{{ Resource.uri }}} **
   //
   // URI representing this resource.
   get uri() {
     return this._uri;
   },
--- a/services/sync/tests/unit/test_resource.js
+++ b/services/sync/tests/unit/test_resource.js
@@ -341,18 +341,18 @@ function run_test() {
 
   _("setHeader(): setting simple header");
   res9.setHeader('X-What-Is-Weave', 'awesome');
   do_check_eq(res9.headers['x-what-is-weave'], 'awesome');
   content = res9.get();
   do_check_eq(content, JSON.stringify({"x-what-is-weave": "awesome"}));
 
   _("setHeader(): setting multiple headers, overwriting existing header");
-  res9.setHeader('X-WHAT-is-Weave', 'more awesomer',
-                 'X-Another-Header', 'hello world');
+  res9.setHeader('X-WHAT-is-Weave', 'more awesomer');
+  res9.setHeader('X-Another-Header', 'hello world');
   do_check_eq(res9.headers['x-what-is-weave'], 'more awesomer');
   do_check_eq(res9.headers['x-another-header'], 'hello world');
   content = res9.get();
   do_check_eq(content, JSON.stringify({"x-another-header": "hello world",
                                        "x-what-is-weave": "more awesomer"}));
 
   _("Setting headers object");
   res9.headers = {};
--- a/services/sync/tests/unit/test_resource_async.js
+++ b/services/sync/tests/unit/test_resource_async.js
@@ -453,18 +453,18 @@ function run_test() {
       do_test_finished();
       next();
     }));
 
   }, function (next) {
 
     _("setHeader(): setting multiple headers, overwriting existing header");
     do_test_pending();
-    res_headers.setHeader('X-WHAT-is-Weave', 'more awesomer',
-                   'X-Another-Header', 'hello world');
+    res_headers.setHeader('X-WHAT-is-Weave', 'more awesomer');
+    res_headers.setHeader('X-Another-Header', 'hello world');
     do_check_eq(res_headers.headers['x-what-is-weave'], 'more awesomer');
     do_check_eq(res_headers.headers['x-another-header'], 'hello world');
     res_headers.get(ensureThrows(function (error, content) {
       do_check_eq(error, null);
       do_check_eq(content, JSON.stringify({"x-another-header": "hello world",
                                            "x-what-is-weave": "more awesomer"}));
       do_test_finished();
       next();