Permalink
Browse files

Ability to remove header fields when passing `null` as value to the `…

…header` method (`.header('X-PINGPONG', null)`)
  • Loading branch information...
1 parent c5197cd commit 7eef94582091bf407e186dca9b6f5046327acc9b @w00fz w00fz committed Jan 30, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 index.js
View
@@ -157,9 +157,12 @@ var Request = prime({
header: function(name, value){
if (typeof name === "object") for (var key in name) this.header(key, name[key])
- else if (arguments.length === 2) this._header[capitalize(name)] = value
- else if (arguments.length === 1) return this._header[capitalize(name)]
else if (!arguments.length) return this._header
+ else if (arguments.length === 1) return this._header[capitalize(name)]
+ else if (arguments.length === 2){
+ if (value == null) delete this._header[capitalize(name)]
+ else this._header[capitalize(name)] = value
+ }
return this
},

0 comments on commit 7eef945

Please sign in to comment.