title: Accessing Response Header Location in Through Python
body: <p>I'm currently trying to access the location field in a response header from a GET request to url: <a href="https://dbr.ee/aUJA/d" rel="nofollow noreferrer">https://dbr.ee/aUJA/d</a>?. Currently, I have been able to view the location field through this Python code:</p>
  
  <pre><code>import requests
  r = requests.get('hhttps://dbr.ee/aUJA/d?', allow_redirects=False, headers={'User-Agent': 'Mozilla/5.0'})
  print r.headers
  </code></pre>
  
  <p>But the output is the wrong location field</p>
  
  <blockquote>
    <p>{'Status': '302 Found', 'X-Request-Id':
    '9e968067-1bee-4cc9-9305-19d45d5cb6ea', 'X-XSS-Protection': '1;
    mode=block', 'X-Content-Type-Options': 'nosniff', 'Transfer-Encoding':
    'chunked', 'Set-Cookie':
    '__cfduid=d21c538fd46c153a046bf461ca281978d1499637583; expires=Mon,
    09-Jul-18 21:59:43 GMT; path=/; domain=.dbr.ee; HttpOnly,
    ahoy_visitor=f4f1c08c-add3-45c0-8325-675b1caf3048; path=/;
    expires=Tue, 09 Jul 2019 21:59:44 -0000,
    ahoy_visit=cdbb4ca8-3272-473c-8562-03596d88ec0f; path=/; expires=Mon,
    10 Jul 2017 01:59:44 -0000, ahoy_track=true; path=/, SERVERID=;
    Expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/', 'X-Runtime':
    '0.006820', 'Server': 'cloudflare-nginx', 'Connection': 'keep-alive',
    'Location': 'hhttps://dbr.ee/aUJA', 'Cache-Control': 'no-cache',
    'Date': 'Sun, 09 Jul 2017 21:59:44 GMT', 'X-Frame-Options':
    'SAMEORIGIN', 'Content-Type': 'text/html; charset=utf-8', 'CF-RAY':
    '37be8d52fdc83822-ATL'}</p>
  </blockquote>
  
  <p>Which is: </p>
  
  <blockquote>
    <p>'Location': 'hhttps://dbr.ee/aUJA'</p>
  </blockquote>
  
  <p>While on the site, the actual response header is this (viewed through Chrome Developer Tools)</p>
  
  <blockquote>
    <p>cache-control:no-cache cf-ray:37be8bacacb437d4-ATL
    content-type:text/html; charset=utf-8 date:Sun, 09 Jul 2017 21:58:36
    GMT
    location:hhttps://s.dbr.ee/sffc/python%2Dlogo%2Dmaster%2Dv3%2DTM.png.zip?temp_url_sig=41ebabb749293a6fe3f3ec82c5ab8ec01b0ed053&amp;temp_url_expires=1499637816&amp;filename=python-logo-master-v3-TM.png.zip;&amp;attachment
    server:cloudflare-nginx
    set-cookie:ahoy_visit=f7d15e42-155c-443f-a637-22c3681863a5; path=/;
    expires=Mon, 10 Jul 2017 01:58:36 -0000
    set-cookie:_dbree_session=U2x6akdCbUJ4c28wdW9MeUFYOXo1QUVxLzV3ZVNxcGtTWW1jbVdkWEdPOWZPMWFiOEl4M0VWY1dOWGNYTjNubEJoVWJHejRCTlQwQlkwL0UrM09QallTMzhFZlU3RFBBTDZxaW9xcGRMeXNlQS9mZFByYTZQWTM0ZlBHMU50ekhhTkt1bjZENXJHRnc2a3dWeGY2d3BBPT0tLVNKOTJnL0Q3SjloWEc0MTZqTnRPNFE9PQ%3D%3D--2dd8f3e77a673f385c9a231af426b55f1d1f71c0;
    domain=dbr.ee; path=/; HttpOnly set-cookie:SERVERID=; Expires=Thu,
    01-Jan-1970 00:00:01 GMT; path=/ status:302 status:302 Found
    x-content-type-options:nosniff x-frame-options:SAMEORIGIN
    x-request-id:f57f3ca7-c7aa-4449-a2d7-7b5014010d0f x-runtime:0.015892
    x-xss-protection:1; mode=block</p>
  </blockquote>
  
  <p>where Location is</p>
  
  <blockquote>
    <p>location:hhttps://s.dbr.ee/sffc/python%2Dlogo%2Dmaster%2Dv3%2DTM.png.zip?temp_url_sig=41ebabb749293a6fe3f3ec82c5ab8ec01b0ed053&amp;temp_url_expires=1499637816&amp;filename=python-logo-master-v3-TM.png.zip;&amp;attachment</p>
  </blockquote>
  
  <p>Which is the download link I am trying to scrape in Python. This appears in Developer Tools after clicking the Direct Download button.</p>
  
  <p>How can I get the header to show me the correct field location in Python?</p>
  
  <p>*links have been modified with h in front of http because of not allowing me to post more than 2 links, but are necessary for context of the question</p>