title: Two HTTP POST headers in a request after modifying the header
body: <p>Despite what the title may suggest, this is not related to the common "preventing double post request" issue.</p>
  
  <p>In my application, I add some data on outgoing HTTP traffic, and with some some websites, I randomly encounter an HTTP POST request that has a double-header, resulting in a server termination, as I assume the server doesn't understand the request and decides to cut me off. As the title says, I'm literally seeing two POST headers in a single request. This only happens when I append some custom HTTP fields to the header. For example, I came across this today when I followed a surveygizmo.com link, as seen in the trace at the bottom of this post.</p>
  
  <p>I cannot understand if it's the browser that's doing something funky because it noticed I've modified some data, or it's something in my LSP application that causes this to happen.</p>
  
  <p>When I debug my application, I only see the intercepted request the first time, which is when I inject the custom data. After that, I don't see the request anywhere except in Wireshark, so it's not like I can remediate the double headers by deleting the redundant data.</p>
  
  <p>Things to note looking at the trace:</p>
  
  <ul>
  <li>The data I'm appending is 'Custom-FieldN:'</li>
  <li>Two almost-identical headers</li>
  <li>Three double-CRLF's in one single request header (how is that possible?)</li>
  </ul>
  
  <p>The Request:</p>
  
  <pre><code>POST http://www.surveygizmo.com/s3/1212345/Who-Are-You HTTP/1.1
  Host: www.surveygizmo.com
  Custom-Field1: UserNameBob
  Custom-Field2: 2578291789
  proxy-connection: keep-alive
  Content-Length: 836
  Cache-Control: max-age=0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Origin: http://www.surveygizmo.com
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryaQraA7ZABICMT6jO
  Referer: http://www.surveygizmo.com/s3/1212345/Who-Are-You
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: en-GB,en;q=0.8,en-US;q=0.6,ja;q=0.4
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Cookie: sg-response-979523-1212345=0%3B1369154430_519ba37e477bc8.35524744%3B1369154430%3BPartial
  
  POST http://www.surveygizmo.com/s3/1212345/Who-Are-You HTTP/1.1
  Host: www.surveygizmo.com
  Custom-Field1: UserNameBob
  Custom-Field2: 2578291789
  proxy-connection: keep-alive
  Content-Length: 836
  Cache-Control: max-age=0
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Origin: http://www.surveygizmo.com
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryaQraA7ZABICMT6jO
  Referer: http://www.surveygizmo.com/s3/1212345/Who-Are-You
  accept-encoding: gzip,deflate
  Accept-Language: en-GB,en;q=0.8,en-US;q=0.6,ja;q=0.4
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Cookie: sg-response-979523-1212345=0%3B1369154430_519ba37e477bc8.35524744%3B1369154430%3BPartial
  
  ------WebKitFormBoundaryaQraA7ZABICMT6jO
  Content-Disposition: form-data; name="sg_navchoice"
  </code></pre>