title: Piping https proxy request over socket connection to named pipe (node.js)
body: <p>I'm trying to build a forward proxy server which can take a request for an http url and pipe that request to an https server listening on a named pipe.</p>
  
  <p>I know I'm missing a step but I'm not sure what it is. This is what I'm trying to use...</p>
  
  <pre><code>function pipeToServer(browserRequest, browserSocket, browserRequestHead){
  
      var targetUrl = url.parse('https://' + browserRequest.url);
      var namedPipe = getNamedPipe()
  
      console.log("Attempting to connect to " + namedPipe)
      var proxySocket = net.connect(namedPipe, function() {
          console.log("Connected to destination server: " + namedPipe)
          console.log("Sending head: " + browserRequestHead)
          browserSocket.write('HTTP/' + browserRequest.httpVersion + ' 200 Connection Established\r\n' +'Proxy-agent: Node-Proxy\r\n' + '\r\n');
          proxySocket.write(browserRequestHead);
          proxySocket.pipe(browserSocket);
          browserSocket.pipe(proxySocket);
      });
  }
  </code></pre>
  
  <p>The connection is successful but the request handler for the target server (listening on the named pipe) is never fired. Interestingly the browserRequestHead always seems to blank too. </p>
  
  <p>I'm lost. Any help appreciated.</p>