summaryrefslogtreecommitdiff
path: root/lib/_http_incoming.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-08-05 18:41:17 -0700
committerisaacs <i@izs.me>2013-08-15 13:57:23 -0700
commite6c81bd67986e672b9b253c62ce6d4a519d3a2e1 (patch)
treec3b95264f84fceae0f353a6cb69a7c8faab92632 /lib/_http_incoming.js
parent1eedbdc361b654a7dc40e7e4514f9ffd6b92f13d (diff)
downloadandroid-node-v8-e6c81bd67986e672b9b253c62ce6d4a519d3a2e1.tar.gz
android-node-v8-e6c81bd67986e672b9b253c62ce6d4a519d3a2e1.tar.bz2
android-node-v8-e6c81bd67986e672b9b253c62ce6d4a519d3a2e1.zip
http: provide access to raw headers/trailers
The format is [key,value,key,value,...] because that seems to have the lowest overhead. Close #4844
Diffstat (limited to 'lib/_http_incoming.js')
-rw-r--r--lib/_http_incoming.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js
index f609e4fc21..8949d4571a 100644
--- a/lib/_http_incoming.js
+++ b/lib/_http_incoming.js
@@ -49,7 +49,9 @@ function IncomingMessage(socket) {
this.httpVersion = null;
this.complete = false;
this.headers = {};
+ this.rawHeaders = [];
this.trailers = {};
+ this.rawTrailers = [];
this.readable = true;
@@ -111,6 +113,27 @@ IncomingMessage.prototype.destroy = function(error) {
};
+IncomingMessage.prototype._addHeaderLines = function(headers, n) {
+ if (headers && headers.length) {
+ var raw, dest;
+ if (this.complete) {
+ raw = this.rawTrailers;
+ dest = this.trailers;
+ } else {
+ raw = this.rawHeaders;
+ dest = this.headers;
+ }
+ raw.push.apply(raw, headers);
+
+ for (var i = 0; i < n; i += 2) {
+ var k = headers[i];
+ var v = headers[i + 1];
+ this._addHeaderLine(k, v, dest);
+ }
+ }
+};
+
+
// Add the given (field, value) pair to the message
//
// Per RFC2616, section 4.2 it is acceptable to join multiple instances of the
@@ -118,9 +141,7 @@ IncomingMessage.prototype.destroy = function(error) {
// multiple values this way. If not, we declare the first instance the winner
// and drop the second. Extended header fields (those beginning with 'x-') are
// always joined.
-IncomingMessage.prototype._addHeaderLine = function(field, value) {
- var dest = this.complete ? this.trailers : this.headers;
-
+IncomingMessage.prototype._addHeaderLine = function(field, value, dest) {
field = field.toLowerCase();
switch (field) {
// Array headers: