Basically, i want to change the way http.js handles headers to use an
array for each http header instead of a comma delimited string for
each http header (commas being inserted between duplicate headers,
which are perfectly legal for certain headers).
parsing cookie headers is a real pain with the way things currently
work and it makes much more sense to me have each header in an array
where i can access all duplicates instead of in a concatenated string
that i have to parse.
The patch would be just this:
http.IncomingMessage.prototype._addHeaderLine = function (field,
value) {
if (field in this.headers) {
this.headers[field].push(value);
} else {
this.headers[field] = [];
this.headers[field].push(value);
}
};
so, for cookie header received from server as follows:
Set-Cookie: Cookie1=blah; expires=Sun, 06-Jan-2013 18:57:25 GMT;
path=/
Set-Cookie: Cookie2=blah; expires=Sun, 06-Jan-2013 18:57:25 GMT;
path=/
Set-Cookie: Cookie3=blah; expires=Sun, 06-Jan-2013 18:57:25 GMT;
path=/
we would get:
headers["Set-Cookie"][0] = "Set-Cookie: Cookie1=blah; expires=Sun, 06-
Jan-2013 18:57:25 GMT; path=/"
headers["Set-Cookie"][1] = "Set-Cookie: Cookie2=blah; expires=Sun, 06-
Jan-2013 18:57:25 GMT; path=/"
headers["Set-Cookie"][2] = "Set-Cookie: Cookie3=blah; expires=Sun, 06-
Jan-2013 18:57:25 GMT; path=/"
instead of:
headers["Set-Cookie"] = "Set-Cookie: Cookie1=blah; expires=Sun, 06-
Jan-2013 18:57:25 GMT; path=/,Set-Cookie: Cookie2=blah; expires=Sun,
06-Jan-2013 18:57:25 GMT; path=/,Set-Cookie: Cookie3=blah;
expires=Sun, 06-Jan-2013 18:57:25 GMT; path=/";
I had a patch for this some time ago, but some things changed, and I
never fixed it up.
Please also change the http client message sending, so that it
supports passing in an object of arrays.
Also, instead of:
> this.headers[field] = [];
> this.headers[field].push(value);
do this:
> this.headers[field] = [value];
--i
+1 for me too. I think Avi Flax also had a patch to support duplicate headers for request/response.
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To po...
> Basically, i want to change the way http.js handles headers to use an
> array for each http header instead of a comma delimited string for
> each http header (commas being inserted between duplicate headers,
> which are perfectly legal for certain headers).
+1 for sure.
On Tue, Apr 13, 2010 at 14:40, Chris Winberry <cpt.o...@gmail.com> wrote:
> +1 for me too. I think Avi Flax also had a patch to support duplicate headers for request/response.
Huh, I don't think so… my only patches were related to the API for
sending the status-line of an HTTP response; I wanted to change the
name of the method and to support custom values for status-text.
--
Avi Flax » Partner » Arc90 » http://arc90.com