something like
var position = fullText.indexOf("\r\n\r\n");
var headertext = fullText.substring(0, position+2);
var header = parseHeaders(headertext);
var body = fullText.substring(position + 4);
On Sat, Feb 1, 2014 at 8:28 PM, Kevin Ingwersen
<[email protected]>wrote:
> Ohai.
>
> For a - local! - project that I am developing, I am calling the php-cgi
> binary for multiple reasons; I want to utilize its header information that
> it spills out. Problem: How do I capture it? Here is an example output -
> with unprintables written in too:
>
> Content-type: text/html\r\n
> Content-length: 1923\r\n
> X-Powered-By: myapp\r\n
> \r\n
> <!DOCTYPE html>\n
> <head>...........
>
> So, I know that the last header sequence is \r\n\r\n (last line plus blank
> line). With some tricks, I can use a yaml-parser to parse the actual
> headers into key-value pairs. BUT, I need to have a good way to strip the
> headers off the content. Example:
>
> function stripHeaders(fullText) {
> // SNIP, strip.
> return { headers: {/*parsed headers*/}, body: body };
> }
>
> Any idea?
>
> Kind regards, Ingwie
>
> --
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.