<blockquote>
<p dir="auto">(gdb) py-list<br>
544            # Guard against that specific failure case.<br>
545            if not isinstance(request, PreparedRequest):<br>
546                raise ValueError('You can only send PreparedRequests.')<br>
547<br>
548            while request.url in self.redirect_cache:<br>
-549                request.url = self.redirect_cache.get(request.url)<br>
550<br>
551            # Set up variables needed for resolve_redirects and dispatching of hooks<br>
552            allow_redirects = kwargs.pop('allow_redirects', True)<br>
553            stream = kwargs.get('stream')<br>
554            timeout = kwargs.get('timeout')</p>
</blockquote>
<p dir="auto">redirect_cache dict could have complementary key/values that forces and enless loop.</p>
<blockquote>
<p dir="auto">(gdb) py-down</p>
<h1 dir="auto">2 Frame 0x7f645c00acd0, for file /test/libs/requests/sessions.py, line 549, in send (self=&lt;Session(cookies=&lt;RequestsCookieJar(_now=1410944130, _policy=&lt;DefaultCookiePolicy(strict_rfc2965_unverifiable=True, strict_ns_domain=0, _allowed_domains=None, rfc2109_as_netscape=None, rfc2965=False, strict_domain=False, _now=1410944130, strict_ns_set_path=False, strict_ns_unverifiable=False, strict_ns_set_initial_dollar=False, hide_cookie2=False, _blocked_domains=(), netscape=True) at remote 0x7f651070c4d0&gt;, _cookies={}, _cookies_lock=&lt;_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=&lt;thread.lock at remote 0x7f6530772dd0&gt;, _RLock__count=0) at remote 0x7f65105a5450&gt;) at remote 0x7f65105a5e10&gt;, stream=False, hooks={'response': []}, redirect_cache={'<a href="http://www.hent" rel="nofollow">http://www.hent</a> aiwe blog.com/': '<a href="http://hent" rel="nofollow">http://hent</a> aiwe blog.com/', '<a href="http://hent" rel="nofollow">http://hent</a> aiwe blog.com/': '<a href="http://www.hent" rel="nofollow">http://www.hent</a> aiwe blog.com/'}, auth=None, trust_env=True, headers=&lt;CaseInsensitiveDict(_store={'accept-encoding': ('Accept-Encoding', 'gzip, deflate'), 'accep...(truncated)</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="request.url = self.redirect_cache.get(request.url)"><pre class="notranslate"><code class="notranslate">request.url = self.redirect_cache.get(request.url)
</code></pre></div>
</blockquote>
<p dir="auto">Current request chain with wget:</p>
<blockquote>
<p dir="auto">$ wget <a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com<br>
--2014-09-18 11:52:20--  <a href="http://www.hent" rel="nofollow">http://www.hent</a> aiwe blog.com/<br>
Resolving <a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com (<a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com)... 109.72.81.172<br>
Connecting to <a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com (<a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com)|109.72.81.172|:80... connected.<br>
HTTP request sent, awaiting response... 301 Moved Permanently<br>
Location: <a href="http://hent" rel="nofollow">http://hent</a> aiwe blog.com/ [following]<br>
--2014-09-18 11:52:20--  <a href="http://hent" rel="nofollow">http://hent</a> aiwe blog.com/<br>
Resolving hent aiwe blog.com (hent aiwe blog.com)... 109.72.81.172<br>
Reusing existing connection to <a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com:80.<br>
HTTP request sent, awaiting response... 301 Moved Permanently<br>
Location: <a href="http://www.hent" rel="nofollow">http://www.hent</a> aiwe blog.com/ [following]<br>
--2014-09-18 11:52:20--  <a href="http://www.hent" rel="nofollow">http://www.hent</a> aiwe blog.com/<br>
Reusing existing connection to <a href="http://www.hent" rel="nofollow">www.hent</a> aiwe blog.com:80.<br>
HTTP request sent, awaiting response... 301 Moved Permanently<br>
Location: <a href="http://hent" rel="nofollow">http://hent</a> aiwe blog.com/ [following]<br>
...</p>
</blockquote>
<p dir="auto">Suggested resolution:</p>
<blockquote>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    redirect_count = 0
    while request.url in self.redirect_cache:
        redirect_count += 1
        if redirect_count &gt; self.max_redirects:
            raise TooManyRedirects
        request.url = self.redirect_cache.get(request.url)"><pre class="notranslate"><code class="notranslate">    redirect_count = 0
    while request.url in self.redirect_cache:
        redirect_count += 1
        if redirect_count &gt; self.max_redirects:
            raise TooManyRedirects
        request.url = self.redirect_cache.get(request.url)
</code></pre></div>
</blockquote>
<p dir="auto">When requesting a URL (get/post), Requests normalizes the URL.<br>
For example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="r = requests.get(&quot;http://123.123.123.123/../../../../../../test&quot;)
print(str(r.status_code))"><pre class="notranslate"><code class="notranslate">r = requests.get("http://123.123.123.123/../../../../../../test")
print(str(r.status_code))
</code></pre></div>
<h2 dir="auto">Expected Result</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /../../../../../../test HTTP/1.1
Host: 123.123.123.123
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0"><pre class="notranslate"><code class="notranslate">GET /../../../../../../test HTTP/1.1
Host: 123.123.123.123
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
</code></pre></div>
<h2 dir="auto">Actual Result</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /test HTTP/1.1
Host: 123.123.123.123
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0"><pre class="notranslate"><code class="notranslate">GET /test HTTP/1.1
Host: 123.123.123.123
Connection: close
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.22.0
</code></pre></div>
<h2 dir="auto">Reproduction Steps</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import requests
r = requests.get(&quot;http://123.123.123.123/../../../../../../test&quot;)
print(str(r.status_code))"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">requests</span>
<span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">get</span>(<span class="pl-s">"http://123.123.123.123/../../../../../../test"</span>)
<span class="pl-en">print</span>(<span class="pl-en">str</span>(<span class="pl-s1">r</span>.<span class="pl-s1">status_code</span>))</pre></div>
<h2 dir="auto">System Information</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: &quot;3.0.4&quot;
  }, 
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;2.8&quot;
  }, 
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;2.8&quot;
  }, 
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;, 
    &quot;version&quot;: &quot;2.7.17&quot;
  }, 
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;5.3.0-51-generic&quot;, 
    &quot;system&quot;: &quot;Linux&quot;
  }, 
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;1010104f&quot;, 
    &quot;version&quot;: &quot;17.5.0&quot;
  }, 
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.22.0&quot;
  }, 
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;1010100f&quot;
  }, 
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.25.6&quot;
  }, 
  &quot;using_pyopenssl&quot;: true
}
"><pre class="notranslate"><code class="notranslate">{
  "chardet": {
    "version": "3.0.4"
  }, 
  "cryptography": {
    "version": "2.8"
  }, 
  "idna": {
    "version": "2.8"
  }, 
  "implementation": {
    "name": "CPython", 
    "version": "2.7.17"
  }, 
  "platform": {
    "release": "5.3.0-51-generic", 
    "system": "Linux"
  }, 
  "pyOpenSSL": {
    "openssl_version": "1010104f", 
    "version": "17.5.0"
  }, 
  "requests": {
    "version": "2.22.0"
  }, 
  "system_ssl": {
    "version": "1010100f"
  }, 
  "urllib3": {
    "version": "1.25.6"
  }, 
  "using_pyopenssl": true
}

</code></pre></div>