| 75 | } |
| 76 | |
| 77 | _flush(callback) { |
| 78 | // Emit the last field |
| 79 | if (this.readingKey) { |
| 80 | // we only have a key if there's something in the buffer. We definitely have no value |
| 81 | if (this.buffer && this.buffer.length) { |
| 82 | this.emitField(this.buffer.toString('ascii')); |
| 83 | } |
| 84 | } else { |
| 85 | // We have a key, we may or may not have a value |
| 86 | this.emitField( |
| 87 | this.key, |
| 88 | this.buffer && this.buffer.length && this.buffer.toString('ascii'), |
| 89 | ); |
| 90 | } |
| 91 | this.buffer = ''; |
| 92 | callback(); |
| 93 | } |
| 94 | |
| 95 | getSection(buffer, i) { |
| 96 | if (i === this.sectionStart) return ''; |