title: Dump the whole HTTP communication as raw data in nodejs
body: <p>I wonder if it's possible to dump the whole HTTP request+response as it goes over the wire.</p>
  
  <p>I don't want to get the method, the path info, the query string, the headers, the cookies, the body and whatever. I could in theory assemble the raw data myself, but then I'd need no HTTP library, right?</p>
  
  <p>Moreover, I want to dump <em>exactly the bytes that go over the wire</em>.</p>
  
  <p>I want the raw data like in this image</p>
  
  <p><a href="https://i.stack.imgur.com/dPo5H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dPo5H.png" alt="http raw data"></a></p>
  
  <p>taken from <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages" rel="noreferrer">this page</a>.</p>
  
  <p>I'm using current <code>node.js</code> as a HTTP <em>client</em> with <code>request</code>. It's plain HTTP (no HTTPS).</p>
  
  <p>Installing a proxy in node.js would be an option, but I don't insist on a library. I could imagine to wrap the socket read and write functions, but I can't see how to get to the socket used.</p>