HTTP trailers

119 views
Skip to first unread message

mnot

unread,
Sep 9, 2010, 2:44:07 AM9/9/10
to nodejs
I've seen a few requests for HTTP trailers, and some interest from ry,
etc.

Use cases include sending debug / trace information, as well as
updating metadata (content-md5, etag, etc.) after dynamic content is
generated.

E.g., the Varnish guys are interested in generating an ETag *after*
ESI processing, so that they don't have to buffer.

Also, I'm talking to a few folks about the possibility of getting
trailers exposed to browser extensions (e.g., FireBug) so that you can
get more page generation stats when you're debugging.

Simple patch:
http://github.com/mnot/node/commit/cccf46f06a38a5fb206a18abb9f4ddc136ebcbe6

This does NOT set the Trailer HTTP header, nor does it sanity check
the value of the trailer, as both would require a fair amount of
overhead/accounting, and presumably anybody using HTTP trailers has a
*bit* of clue. Also, the requirement to set a Trailer header
advertising what's going to be a trailer is a SHOULD NOT, not a MUST
NOT.

Also, it silently discards the trailers if the message is sent without
chunked encoding, as trailers by definition are optional anyway.

mnot

unread,
Sep 9, 2010, 7:45:36 PM9/9/10
to nodejs
...with documentation at
http://github.com/mnot/node/commit/d78dc2d6f8eb7a32b2b4cb027123fbb0cd7f40a8

On Sep 9, 4:44 pm, mnot <m...@mnot.net> wrote:
> I've seen a few requests for HTTP trailers, and some interest from ry,
> etc.
>
> Use cases include sending debug / trace information, as well as
> updating metadata (content-md5, etag, etc.) after dynamic content is
> generated.
>
> E.g., the Varnish guys are interested in generating an ETag *after*
> ESI processing, so that they don't have to buffer.
>
> Also, I'm talking to a few folks about the possibility of getting
> trailers exposed to browser extensions (e.g., FireBug) so that you can
> get more page generation stats when you're debugging.
>
> Simple patch:
>  http://github.com/mnot/node/commit/cccf46f06a38a5fb206a18abb9f4ddc136...

r...@tinyclouds.org

unread,
Sep 9, 2010, 9:57:33 PM9/9/10
to nod...@googlegroups.com
On Wed, Sep 8, 2010 at 11:44 PM, mnot <mn...@mnot.net> wrote:
> I've seen a few requests for HTTP trailers, and some interest from ry,
> etc.

Sure, I'll take the patch. Can I have a test that exercises that method?


Node's parser supports trailing headers, it would be nice to expose
them somehow to the JS layer...

mnot

unread,
Sep 13, 2010, 2:46:49 AM9/13/10
to nodejs


On Sep 10, 11:57 am, r...@tinyclouds.org wrote:
> On Wed, Sep 8, 2010 at 11:44 PM, mnot <m...@mnot.net> wrote:
> > I've seen a few requests for HTTP trailers, and some interest from ry,
> > etc.
>
> Sure, I'll take the patch. Can I have a test that exercises that method?

No problem; will get it in soon. I'll send a pull request with the
patch, documentation and test all in one, if that's OK.

> Node's parser supports trailing headers, it would be nice to expose
> them somehow to the JS layer...

I had a quick look and didn't see it in http_parser.c -- could you
point me in the right direction?

Thanks,

r...@tinyclouds.org

unread,
Sep 13, 2010, 3:12:52 AM9/13/10
to nod...@googlegroups.com
On Sun, Sep 12, 2010 at 11:46 PM, mnot <mn...@mnot.net> wrote:
>
>
> On Sep 10, 11:57 am, r...@tinyclouds.org wrote:
>> On Wed, Sep 8, 2010 at 11:44 PM, mnot <m...@mnot.net> wrote:
>> > I've seen a few requests for HTTP trailers, and some interest from ry,
>> > etc.
>>
>> Sure, I'll take the patch. Can I have a test that exercises that method?
>
> No problem; will get it in soon. I'll send a pull request with the
> patch, documentation and test all in one, if that's OK.

Thanks. Yes, that's the preferred method.

>> Node's parser supports trailing headers, it would be nice to expose
>> them somehow to the JS layer...
>
> I had a quick look and didn't see it in http_parser.c -- could you
> point me in the right direction?

Just a server/client example in the test/simple directory in Node,
please. The http_parser already has tests for trailing headers.

Mark Nottingham

unread,
Sep 14, 2010, 2:32:38 AM9/14/10
to nod...@googlegroups.com
For those that are interested, pull request at:
http://github.com/ry/node/pull/275

Cheers,

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


--
Mark Nottingham http://www.mnot.net/

Paul Querna

unread,
Sep 14, 2010, 5:19:41 PM9/14/10
to nod...@googlegroups.com
Very cool.

I'm not sure about the interface though. It seems like it should be
something more like:

response.addTrailers({'TraceInfo': "everything went well.",
"Content-MD5", "xxxx"});

To match how the other header interfaces are using objects, rather
than passing a key/value in the parameters.

r...@tinyclouds.org

unread,
Sep 14, 2010, 6:26:02 PM9/14/10
to nod...@googlegroups.com
On Mon, Sep 13, 2010 at 11:32 PM, Mark Nottingham <mn...@mnot.net> wrote:
> For those that are interested, pull request at:
>  http://github.com/ry/node/pull/275

Thanks Mark. Landed in 4fe3007.

I used Paul's API suggestion.

Mark Nottingham

unread,
Sep 14, 2010, 7:59:48 PM9/14/10
to nod...@googlegroups.com
Thanks. I figured there'd be discussion about the API; I'm fine with that (although there's probably a more general discussion about headers to be had, as on the rawHeaders thread...).

Cheers,

Reply all
Reply to author
Forward
0 new messages