var stream = require('stream')
  , concat = require('concat-stream')
  , http = require('http')
  , DuplexCombination = require('duplex-combination');

module.exports = function (opt) {
  opt = opt  || {}

  var input = new stream.PassThrough()
    , output = new stream.PassThrough()
    , dup = new DuplexCombination(output,input)

  dup.on('pipe', function (res) {
    var statusText, header = ''

    if (opt.printRequestHeader) {
      header += res.req._header
    }

    statusText = res.statusCode + ' ' + http.STATUS_CODES[res.statusCode]
    header += 'HTTP/1.1 ' + statusText + '\n'
    header += formatHeaders(res.headers, opt.ignoreHeaders) + '\n\n'

    if (opt.prettifyJSON && res.headers['content-type'] === 'application/json') {
      input.pipe(concat(function (json) {
        json = JSON.stringify(JSON.parse(json), true, 2)
        output.end(header + json)
      }))
    } else {
      output.write(header)
      input.pipe(output)
    }
  })

  return dup
}

function formatHeaders(headers, ignored) {
  ignored = (ignored || []).map(function (s) {
    return s.toLowerCase()
  })
  var str = Object.keys(headers).map(function (h) {
    if (ignored.indexOf(h) > -1) return false
    return uppercaseWords(h) + ': ' + headers[h]
  }).filter(Boolean).join('\n')
  return str
}

function uppercaseWords(str) {
  return str.replace(/(^|\W)(\w)/g, function (m) {
    return m.toUpperCase()
  })
}

@@ -327,16 +327,116 @@
 input)%0A%0A
+  opt.ignoreHeaders = (opt.ignoreHeaders %7C%7C %5B%5D).map(function (s) %7B%0A    return s.toLowerCase()%0A  %7D)%0A%0A
   dup.on
@@ -524,16 +524,27 @@
 stHeader
+ && res.req
 ) %7B%0A    
@@ -559,150 +559,62 @@
  += 
-res.req._header%0A    %7D%0A%0A    statusText = res.statusCode + ' ' + http.STATUS_CODES%5Bres.statusCode%5D%0A    header += 'HTTP/1.1 ' + statusText + '%5Cn'
+formatRequestHeader(res.req, opt.ignoreHeaders)%0A    %7D%0A
 %0A   
@@ -634,27 +634,26 @@
 rmat
+Response
 Header
-s
 (res
-.headers
 , op
@@ -672,17 +672,8 @@
 ers)
- + '%5Cn%5Cn'
 %0A%0A  
@@ -1009,17 +1009,22 @@
 atHeader
-s
+Object
 (headers
@@ -1042,32 +1042,34 @@
 %7B%0A  
-ignored = (ignored %7C%7C %5B%5D
+return Object.keys(headers
 ).ma
@@ -1076,33 +1076,33 @@
 p(function (
-s
+h
 ) %7B%0A    
 return s.toL
@@ -1093,72 +1093,262 @@
     
-return s.toLowerCase()%0A  %7D)%0A  var str = Object.keys(headers).map
+if (ignored.indexOf(h) %3E -1) return false%0A    return uppercaseWords(h) + ': ' + headers%5Bh%5D%0A  %7D).filter(Boolean).join('%5Cn')%0A%7D%0A%0Afunction formatRequestHeader(req, ignored) %7B%0A  var header = ''%0A  if (req._header) %7B%0A    header += req._header.split('%5Cn').filter
 (fun
@@ -1350,33 +1350,36 @@
 r(function (
-h
+line
 ) %7B%0A    
 if (ignored.
@@ -1370,52 +1370,261 @@
     
-if (ignored.indexOf(h) %3E -1) return false
+  var headerName = line.toLowerCase().split(':')%5B0%5D%0A      return ignored.indexOf(headerName) %3C 0%0A    %7D).join('%5Cn')%0A  %7D else %7B%0A    header += req.method + ' ' + req.path + ' HTTP/1.1%5Cn'%0A    header += formatHeaderObject(req._headers, ignored) + '%5Cn%5Cn'
 %0A  
+%7D%0A
   re
@@ -1632,90 +1632,266 @@
 urn 
-uppercaseWords(h)
+header%0A%7D%0A%0Afunction formatResponseHeader(res, ignored) %7B%0A  var statusText = res.statusCode
  + '
-:
  ' + h
-eaders%5Bh%5D%0A  %7D).filter(Boolean).join('%5Cn')%0A  return str
+ttp.STATUS_CODES%5Bres.statusCode%5D%0A    , header = 'HTTP/1.1 ' + statusText + '%5Cn'%0A%0A  header += formatHeaderObject(res.headers, ignored)%0A%0A  return header + '%5Cn%5Cn'
 %0A%7D%0A%0A

Add support for printRequestHeader w/ http-browserify responses; allow ignoring of request headers