title: How to correctly respond to HTTP CONNECT in Google Chrome
body: <p>I am building a Proxy server, upon receiving a HTTP CONNECT request I establish a connection to the destination server and if successful return</p>
  
  <pre><code>HTTP/1.1 200 Connection established
  &lt;&lt;empty line&gt;&gt;
  </code></pre>
  
  <p>In Firefox this results in the opening of a tunnel and data being exchanged, loading and eventually delivered/rendered in the browser</p>
  
  <p>In Google Chrome, I immediately just see:</p>
  
  <pre><code>ERR_TUNNEL_CONNECTION_FAILED
  </code></pre>
  
  <p>As the server appears to be working fine for Firefox but not for Chrome I can only assume that Chrome expects a different response back. Does anyone know what I am doing wrong here?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I found <a href="https://code.google.com/p/chromium/issues/detail?id=114255" rel="noreferrer">this</a> chromium issue here which describes the same symptoms - user gets ERR_TUNNEL_CONNECTION_FAILED. I enabled the --log-net-log command line parameter and can see in the log that the ERR_TUNNEL_CONNECTION_FAILED error occurs directly after receiving my 200 Connection established proxy response. </p>
  
  <p>Higher up between the request and the response I see a -109 error which corresponds to ADDRESS_UNREACHABLE.</p>
  
  <p>I have included an extract below of what I think the relevant parts of the net-log are:</p>
  
  <pre><code>{"params":{"headers":["Host: mail.google.com","Proxy-Connection: keep-alive","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"],"line":"CONNECT mail.google.com:443 HTTP/1.1\r\n"},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":125},
  {"params":{"headers":["Host: mail.google.com","Proxy-Connection: keep-alive","User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"],"line":"CONNECT mail.google.com:443 HTTP/1.1\r\n"},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":129},
  {"params":{"byte_count":227},"phase":0,"source":{"id":822,"type":5},"time":"331488980","type":61},
  {"phase":2,"source":{"id":822,"type":5},"time":"331488981","type":124},
  {"phase":1,"source":{"id":822,"type":5},"time":"331488981","type":126},
  {"phase":1,"source":{"id":822,"type":5},"time":"331488981","type":207},
  {"params":{"address_family":0,"allow_cached_response":true,"host":"mail.google.com:0","is_speculative":false,"source_dependency":{"id":0,"type":0}},"phase":1,"source":{"id":823,"type":8},"time":"331489008","type":4},
  {"params":{"source_dependency":{"id":823,"type":8}},"phase":1,"source":{"id":824,"type":21},"time":"331489008","type":299},
  {"params":{"source_dependency":{"id":824,"type":21}},"phase":1,"source":{"id":825,"type":14},"time":"331489008","type":34},
  {"params":{"address":"[2001:4860:4860::8888]:53"},"phase":1,"source":{"id":825,"type":14},"time":"331489008","type":70},
  {"params":{"net_error":-109},"phase":2,"source":{"id":825,"type":14},"time":"331489008","type":70},
  {"phase":2,"source":{"id":825,"type":14},"time":"331489008","type":34},
  {"phase":2,"source":{"id":824,"type":21},"time":"331489008","type":299},
  {"phase":0,"source":{"id":823,"type":8},"time":"331489008","type":6},
  {"phase":2,"source":{"id":823,"type":8},"time":"331489008","type":4},
  {"params":{"byte_count":74},"phase":0,"source":{"id":822,"type":5},"time":"331489052","type":63},
  {"phase":2,"source":{"id":822,"type":5},"time":"331489052","type":207},
  {"params":{"headers":["HTTP/1.1 200 Connection established"]},"phase":0,"source":{"id":822,"type":5},"time":"331489052","type":127},
  {"params":{"net_error":-111},"phase":2,"source":{"id":822,"type":5},"time":"331489052","type":126},
  </code></pre>
  
  <p>If you need to see more of the log I have posted the whole log <a href="https://drive.google.com/file/d/0B8JuL0rVSQEKMWxhaC1XYU5hTDg/edit?usp=sharing" rel="noreferrer">here</a></p>