Parse Buffer into an http.IncomingMessage

192 views
Skip to first unread message

Chris Ackerman

unread,
Aug 24, 2013, 12:31:21 PM8/24/13
to nod...@googlegroups.com
I have a net.Server listening and on 'data' emit, depending on the contents of the buffer, I may want to emulate a 'request' event passing IncomingMessage and ServerResponse instances. Looking at the node source lib sub directory, it looks like there's no sanctioned way to create the IncomingMessage from userland. If I could, then creating a ServerResponse would be trivial since it can be constructed from the request.

Is there some way to create an IncomingMessage instance from a Buffer that I'm missing?

Dmitry Unkovsky

unread,
Aug 29, 2013, 9:12:00 AM8/29/13
to nod...@googlegroups.com
Not that easy, but you could do something like what
parserOnHeadersComplete does in _http_common.js together with
connectionListener in _http_server.js. If you're really into it.
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> 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?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nodejs+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
DU
Reply all
Reply to author
Forward
0 new messages