title: How to get port number from an HTTP response, using Python?
body: <p>I am trying to simulate Network Address Translation for some test code. I am mapping virtual users to high port numbers, then, when I want to test a request from user 1, I send it from port 6000 (user 2, from 6001, etc).</p>
  
  <p>However, I can't see the port number in the response. </p>
  
  <pre><code>        connection = httplib.HTTPConnection("the.company.lan", port=80, strict=False,   
                                            timeout=10, source_address=("10.129.38.51", 6000))
          connection.request("GET", "/portal/index.html")
          httpResponse = connection.getresponse()
          connection.close()
  </code></pre>
  
  <p><code>httpResponse.status</code> is 200, but I don't see the port number anywhere in the response headers.</p>
  
  <p>Maybe I should be using some lower level socket functionality? If so, which is simplest and supports both HTTP and FTP? Btw, I only want to use built-in modules, nothing which I have to install.</p>
  
  <hr>
  
  <p>[Update] I should have made it clearer; I really do need to get the actual port number received in the response, not just remember it. </p>