Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added remove_header to transaction and documented it.

  • Loading branch information...
commit 2f11f332a5e567eb64b260fd514354e7109c8242 1 parent 311688c
@baudehlo authored
Showing with 20 additions and 2 deletions.
  1. +4 −1 docs/Header.md
  2. +4 −0 docs/Transaction.md
  3. +12 −1 transaction.js
View
5 docs/Header.md
@@ -26,7 +26,10 @@ they may have used.
* header.remove(key)
-Removes all headers with the given name.
+Removes all headers with the given name. DO NOT USE. This is transparent to
+the transaction and it will not see the header(s) you removed. Instead use
+`transaction.remove_header(key)` which will also correct the data part of
+the email.
* header.add(key, value)
View
4 docs/Transaction.md
@@ -35,6 +35,10 @@ A safe place to store transaction specific values.
Adds a header to the email.
+* transaction.remove_header(key)
+
+Deletes a header from the email.
+
* transaction.header
The header of the email. See `Header Object`.
View
13 transaction.js
@@ -52,7 +52,18 @@ Transaction.prototype.add_data = function(line) {
Transaction.prototype.add_header = function(key, value) {
this.header.add(key, value);
- this.data_lines = this.header.lines().concat(this.data_lines.slice(this.header_pos));
+ this.reset_headers();
+};
+
+Transaction.prototype.reset_headers = function () {
+ var header_lines = this.header.lines();
+ this.data_lines = header_lines.concat(this.data_lines.slice(this.header_pos));
+ this.header_pos = header_lines.length();
+};
+
+Transaction.prototype.remove_header = function (key) {
+ this.header.remove(key);
+ this.reset_headers();
};
Transaction.prototype.attachment_hooks = function (start, data, end) {
Please sign in to comment.
Something went wrong with that request. Please try again.