http headers again

21 views
Skip to first unread message

billywhizz

unread,
Apr 13, 2010, 2:17:17 PM4/13/10
to nodejs
i know i've raised this before and i apologise if i am being a pain in
the ass, but i've never had a response and i'd like to get a response
from someone in core development on whether it can be implemented in
node.js.

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=/";


Isaac Schlueter

unread,
Apr 13, 2010, 2:32:59 PM4/13/10
to nod...@googlegroups.com
+1

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

Chris Winberry

unread,
Apr 13, 2010, 2:40:34 PM4/13/10
to nod...@googlegroups.com

+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...

Avi Flax

unread,
Apr 13, 2010, 2:45:08 PM4/13/10
to nod...@googlegroups.com
On Tue, Apr 13, 2010 at 14:17, billywhizz <apjo...@gmail.com> wrote:

> 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

Chris Winberry

unread,
Apr 20, 2010, 3:06:57 PM4/20/10
to nod...@googlegroups.com

I'm confusing desired features =)

I haven't forgotten about Readability, I've just extended my road trip
by a week or so. I'll be in touch with you as soon as I return...

- Chris
> --
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en
> .
>

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Reply all
Reply to author
Forward
0 new messages