<p dir="auto">Sending an https request with timeout, does not make retries when it gets a timeout.<br>
Code:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import requests
s = requests.session()
s.mount('https://localhost:10000', requests.adapters.HTTPAdapter(max_retries = 3))
s.post('https://localhost:10000', timeout = 3)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">requests</span>
<span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">session</span>()
<span class="pl-s1">s</span>.<span class="pl-en">mount</span>(<span class="pl-s">'https://localhost:10000'</span>, <span class="pl-s1">requests</span>.<span class="pl-s1">adapters</span>.<span class="pl-v">HTTPAdapter</span>(<span class="pl-s1">max_retries</span> <span class="pl-c1">=</span> <span class="pl-c1">3</span>))
<span class="pl-s1">s</span>.<span class="pl-en">post</span>(<span class="pl-s">'https://localhost:10000'</span>, <span class="pl-s1">timeout</span> <span class="pl-c1">=</span> <span class="pl-c1">3</span>)</pre></div>
<p dir="auto">Raises this exception (with no retries):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="File &quot;/usr/local/lib/python2.7/dist-packages/requests/sessions.py&quot;, line 498, in post
    return self.request('POST', url, data=data, **kwargs)
  File &quot;/usr/local/lib/python2.7/dist-packages/requests/sessions.py&quot;, line 456, in request
    resp = self.send(prep, **send_kwargs)
  File &quot;/usr/local/lib/python2.7/dist-packages/requests/sessions.py&quot;, line 559, in send
    r = adapter.send(request, **kwargs)
  File &quot;/usr/local/lib/python2.7/dist-packages/requests/adapters.py&quot;, line 382, in send
    raise SSLError(e, request=request)
SSLError: _ssl.c:492: The handshake operation timed out"><pre class="notranslate"><code class="notranslate">File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 498, in post
    return self.request('POST', url, data=data, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 382, in send
    raise SSLError(e, request=request)
SSLError: _ssl.c:492: The handshake operation timed out
</code></pre></div>
<p dir="auto">A similar request (even using the same session object) with <code class="notranslate">http</code> instead of <code class="notranslate">https</code> raises the exception <code class="notranslate">Timeout: HTTPConnectionPool(host='localhost', port=10000): Read timed out. (read timeout=1)</code> after 3 retries as expected.</p>
<p dir="auto">This does not seem to be a general issue with ssl + retries - I've successfully used both</p>
<p dir="auto">The problem was found on version 2.3.0 both on linux and windows, and also on the latest version - 2.4.3 (tried on linux only).</p>
<p dir="auto">Alternative title: <em>A bugfix in urlib3 raises a new bug in requests.</em> (I tried to figure out what changed in <code class="notranslate">urllib3</code> but was not able to do so).</p>
<p dir="auto">I believe the issue has to do with these lines (</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/psf/requests/blob/ac3be98b19f4d09c6a970b271a3ae30f3d0858f7/requests/adapters.py#L509-L539">requests/requests/adapters.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 509 to 539
      in
      <a data-pjax="true" class="commit-tease-sha" href="/psf/requests/commit/ac3be98b19f4d09c6a970b271a3ae30f3d0858f7">ac3be98</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L509" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="509"></td>
          <td id="LC509" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">try</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L510" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="510"></td>
          <td id="LC510" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">skip_host</span> <span class="pl-c1">=</span> <span class="pl-s">"Host"</span> <span class="pl-c1">in</span> <span class="pl-s1">request</span>.<span class="pl-s1">headers</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L511" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="511"></td>
          <td id="LC511" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">low_conn</span>.<span class="pl-en">putrequest</span>( </td>
        </tr>

        <tr class="border-0">
          <td id="L512" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="512"></td>
          <td id="LC512" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">request</span>.<span class="pl-s1">method</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L513" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="513"></td>
          <td id="LC513" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">url</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L514" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="514"></td>
          <td id="LC514" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">skip_accept_encoding</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L515" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="515"></td>
          <td id="LC515" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">skip_host</span><span class="pl-c1">=</span><span class="pl-s1">skip_host</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L516" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="516"></td>
          <td id="LC516" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     ) </td>
        </tr>

        <tr class="border-0">
          <td id="L517" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="517"></td>
          <td id="LC517" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L518" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="518"></td>
          <td id="LC518" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">for</span> <span class="pl-s1">header</span>, <span class="pl-s1">value</span> <span class="pl-c1">in</span> <span class="pl-s1">request</span>.<span class="pl-s1">headers</span>.<span class="pl-en">items</span>(): </td>
        </tr>

        <tr class="border-0">
          <td id="L519" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="519"></td>
          <td id="LC519" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">low_conn</span>.<span class="pl-en">putheader</span>(<span class="pl-s1">header</span>, <span class="pl-s1">value</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L520" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="520"></td>
          <td id="LC520" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L521" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="521"></td>
          <td id="LC521" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">low_conn</span>.<span class="pl-en">endheaders</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L522" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="522"></td>
          <td id="LC522" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L523" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="523"></td>
          <td id="LC523" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-s1">request</span>.<span class="pl-s1">body</span>: </td>
        </tr>

        <tr class="border-0">
          <td id="L524" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="524"></td>
          <td id="LC524" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">low_conn</span>.<span class="pl-en">send</span>(<span class="pl-en">hex</span>(<span class="pl-en">len</span>(<span class="pl-s1">i</span>))[<span class="pl-c1">2</span>:].<span class="pl-en">encode</span>(<span class="pl-s">"utf-8"</span>)) </td>
        </tr>

        <tr class="border-0">
          <td id="L525" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="525"></td>
          <td id="LC525" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">low_conn</span>.<span class="pl-en">send</span>(<span class="pl-s">b"<span class="pl-cce">\r</span><span class="pl-cce">\n</span>"</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L526" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="526"></td>
          <td id="LC526" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">low_conn</span>.<span class="pl-en">send</span>(<span class="pl-s1">i</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L527" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="527"></td>
          <td id="LC527" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">low_conn</span>.<span class="pl-en">send</span>(<span class="pl-s">b"<span class="pl-cce">\r</span><span class="pl-cce">\n</span>"</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L528" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="528"></td>
          <td id="LC528" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">low_conn</span>.<span class="pl-en">send</span>(<span class="pl-s">b"0<span class="pl-cce">\r</span><span class="pl-cce">\n</span><span class="pl-cce">\r</span><span class="pl-cce">\n</span>"</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L529" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="529"></td>
          <td id="LC529" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L530" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="530"></td>
          <td id="LC530" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-c"># Receive the response from the server</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L531" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="531"></td>
          <td id="LC531" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">low_conn</span>.<span class="pl-en">getresponse</span>() </td>
        </tr>

        <tr class="border-0">
          <td id="L532" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="532"></td>
          <td id="LC532" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">  </td>
        </tr>

        <tr class="border-0">
          <td id="L533" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="533"></td>
          <td id="LC533" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-s1">resp</span> <span class="pl-c1">=</span> <span class="pl-v">HTTPResponse</span>.<span class="pl-en">from_httplib</span>( </td>
        </tr>

        <tr class="border-0">
          <td id="L534" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="534"></td>
          <td id="LC534" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">r</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L535" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="535"></td>
          <td id="LC535" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">pool</span><span class="pl-c1">=</span><span class="pl-s1">conn</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L536" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="536"></td>
          <td id="LC536" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">connection</span><span class="pl-c1">=</span><span class="pl-s1">low_conn</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L537" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="537"></td>
          <td id="LC537" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">preload_content</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L538" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="538"></td>
          <td id="LC538" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">decode_content</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L539" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="539"></td>
          <td id="LC539" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     ) </td>
        </tr>
    </tbody></table>
  </div>
</div>
). It seems like the library is uploading the body with a <code class="notranslate">PUT</code> while it should first follow the redirection before uploading the body.<p></p>
<p dir="auto">We've traced this down, confusingly, to different behavior for <code class="notranslate">requests</code> depending on the <code class="notranslate">urllib3</code> version.  Essentially, on an older <code class="notranslate">urllib3</code>, python <code class="notranslate">requests</code> will send the entire file twice(!) which can be time-consuming for larger files. This is <strong>incorrect</strong> behavior. Upon a <code class="notranslate">PUT</code> to a node that responds with a 307/redirect, <code class="notranslate">requests</code> sends the whole body then handles redirects, and then <code class="notranslate">PUT</code> again.</p>
<h2 dir="auto">Expected Result</h2>
<p dir="auto">I expected for a <code class="notranslate">PUT</code> request receiving a 307 to redirect and re-<code class="notranslate">PUT</code> (It does) but doesn't send data immediately until after redirects are resolved. This should probably behave more like what <code class="notranslate">curl</code> is doing (see output below).</p>
<h2 dir="auto">Actual Result</h2>
<p dir="auto">Data is sent immediately instead of checking for redirects, causing the file to be sent at least twice.</p>
<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
import subprocess
import logging

# These two lines enable debugging at httplib level (requests-&gt;urllib3-&gt;http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
    import http.client as http_client
except ImportError:
    # Python 2
    import httplib as http_client
http_client.HTTPConnection.debuglevel = 1

# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger(&quot;requests.packages.urllib3&quot;)
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

print(&quot;working with big file&quot;)
fpath = &quot;big_file.txt&quot;
fp = open(fpath, 'rb')

sever = &quot;https:// .... &quot; # our internal server

try:
    ret = requests.put(f&quot;{server}&quot;, headers={&quot;Content-Type&quot;:&quot;application/octet-stream&quot;}, data=fp, allow_redirects = True, stream = True)
    print(ret.status_code)
except Exception as exception:
    print(exception)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">requests</span>
<span class="pl-k">import</span> <span class="pl-s1">subprocess</span>
<span class="pl-k">import</span> <span class="pl-s1">logging</span>

<span class="pl-c"># These two lines enable debugging at httplib level (requests-&gt;urllib3-&gt;http.client)</span>
<span class="pl-c"># You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.</span>
<span class="pl-c"># The only thing missing will be the response.body which is not logged.</span>
<span class="pl-k">try</span>:
    <span class="pl-k">import</span> <span class="pl-s1">http</span>.<span class="pl-s1">client</span> <span class="pl-k">as</span> <span class="pl-s1">http_client</span>
<span class="pl-k">except</span> <span class="pl-v">ImportError</span>:
    <span class="pl-c"># Python 2</span>
    <span class="pl-k">import</span> <span class="pl-s1">httplib</span> <span class="pl-k">as</span> <span class="pl-s1">http_client</span>
<span class="pl-s1">http_client</span>.<span class="pl-v">HTTPConnection</span>.<span class="pl-s1">debuglevel</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>

<span class="pl-c"># You must initialize logging, otherwise you'll not see debug output.</span>
<span class="pl-s1">logging</span>.<span class="pl-en">basicConfig</span>()
<span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>().<span class="pl-en">setLevel</span>(<span class="pl-s1">logging</span>.<span class="pl-v">DEBUG</span>)
<span class="pl-s1">requests_log</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>(<span class="pl-s">"requests.packages.urllib3"</span>)
<span class="pl-s1">requests_log</span>.<span class="pl-en">setLevel</span>(<span class="pl-s1">logging</span>.<span class="pl-v">DEBUG</span>)
<span class="pl-s1">requests_log</span>.<span class="pl-s1">propagate</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>

<span class="pl-en">print</span>(<span class="pl-s">"working with big file"</span>)
<span class="pl-s1">fpath</span> <span class="pl-c1">=</span> <span class="pl-s">"big_file.txt"</span>
<span class="pl-s1">fp</span> <span class="pl-c1">=</span> <span class="pl-en">open</span>(<span class="pl-s1">fpath</span>, <span class="pl-s">'rb'</span>)

<span class="pl-s1">sever</span> <span class="pl-c1">=</span> <span class="pl-s">"https:// .... "</span> <span class="pl-c"># our internal server</span>

<span class="pl-k">try</span>:
    <span class="pl-s1">ret</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">put</span>(<span class="pl-s">f"<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">server</span><span class="pl-kos">}</span></span>"</span>, <span class="pl-s1">headers</span><span class="pl-c1">=</span>{<span class="pl-s">"Content-Type"</span>:<span class="pl-s">"application/octet-stream"</span>}, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">fp</span>, <span class="pl-s1">allow_redirects</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">stream</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>)
    <span class="pl-en">print</span>(<span class="pl-s1">ret</span>.<span class="pl-s1">status_code</span>)
<span class="pl-k">except</span> <span class="pl-v">Exception</span> <span class="pl-k">as</span> <span class="pl-s1">exception</span>:
    <span class="pl-en">print</span>(<span class="pl-s1">exception</span>)</pre></div>
<p dir="auto">Meanwhile, <code class="notranslate">curl</code> seems to do the RightThing™ here:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ time curl -L -v  https://server/large_file.txt --upload-file ./big_file.txt
* About to connect() to server port 443 (#0)
*   Trying ADDRESS...
* Connected to server(ADDRESS) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS: client certificate not found (nickname not specified)
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
*     subject: CN=CN_INFO
*     start date: Jun 27 21:45:02 2022 GMT
*     expire date: Aug 01 21:45:02 2023 GMT
*     common name: SERVER
*     issuer: CN=CN_AUTHORITY
&gt; PUT /large_file.txt HTTP/1.1
&gt; User-Agent: curl/7.29.0
&gt; Host: server:443
&gt; Accept: */*
&gt; Content-Length: 1048576
&gt; Expect: 100-continue
&gt; 
&lt; HTTP/1.1 307 TEMPORARY_REDIRECT
&lt; Connection: Keep-Alive
&lt; Server: XrootD/5.5.5
&lt; Content-Length: 0
&lt; Date: Tue, 20 Dec 2022 14:34:33 GMT
&lt; ETag: &quot;751376756371357696:00000000&quot;
&lt; Location: http://server_redirect/large_file.txt
&lt; 
* Closing connection 0
* Issue another request to this URL: 'http://server_redirect/large_file.txt'
* About to connect() to server_redirect port 443 (#1)
*   Trying ADDRESS...
* Connected to server_redirect (ADDRESS) port 443 (#1)
&gt; PUT /server_redirect/large_file.txt HTTP/1.1
&gt; User-Agent: curl/7.29.0
&gt; Host: server_redirect:443
&gt; Accept: */*
&gt; Content-Length: 1048576
&gt; Expect: 100-continue
&gt; 
&lt; HTTP/1.1 100 Continue
&lt; Connection: Close
&lt; Server: OURSERVER
&lt; Date: Tue, 20 Dec 2022 14:34:33 GMT
* We are completely uploaded and fine
&lt; HTTP/1.1 201 CREATED
&lt; Connection: Keep-Alive
&lt; Server: OURSERVER
&lt; Content-Length: 0"><pre class="notranslate">$ <span class="pl-k">time</span> curl -L -v  https://server/large_file.txt --upload-file ./big_file.txt
<span class="pl-k">*</span> About to <span class="pl-en">connect</span>() to server port 443 (<span class="pl-c"><span class="pl-c">#</span>0)</span>
<span class="pl-k">*</span>   Trying ADDRESS...
<span class="pl-k">*</span> Connected to server(ADDRESS) port 443 (<span class="pl-c"><span class="pl-c">#</span>0)</span>
<span class="pl-k">*</span> Initializing NSS with certpath: sql:/etc/pki/nssdb
<span class="pl-k">*</span>   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
<span class="pl-k">*</span> NSS: client certificate not found (nickname not specified)
<span class="pl-k">*</span> SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
<span class="pl-k">*</span> Server certificate:
<span class="pl-k">*</span>     subject: CN=CN_INFO
<span class="pl-k">*</span>     start date: Jun 27 21:45:02 2022 GMT
<span class="pl-k">*</span>     expire date: Aug 01 21:45:02 2023 GMT
<span class="pl-k">*</span>     common name: SERVER
<span class="pl-k">*</span>     issuer: CN=CN_AUTHORITY
<span class="pl-k">&gt;</span> PUT /large_file.txt HTTP/1.1
<span class="pl-k">&gt;</span> User-Agent: curl/7.29.0
<span class="pl-k">&gt;</span> Host: server:443
<span class="pl-k">&gt;</span> Accept: <span class="pl-k">*</span>/<span class="pl-k">*</span>
<span class="pl-k">&gt;</span> Content-Length: 1048576
<span class="pl-k">&gt;</span> Expect: 100-continue
<span class="pl-k">&gt;</span> 
<span class="pl-k">&lt;</span> HTTP/1.1 307 TEMPORARY_REDIRECT
<span class="pl-k">&lt;</span> Connection: Keep-Alive
<span class="pl-k">&lt;</span> Server: XrootD/5.5.5
<span class="pl-k">&lt;</span> Content-Length: 0
<span class="pl-k">&lt;</span> Date: Tue, 20 Dec 2022 14:34:33 GMT
<span class="pl-k">&lt;</span> ETag: <span class="pl-s"><span class="pl-pds">"</span>751376756371357696:00000000<span class="pl-pds">"</span></span>
<span class="pl-k">&lt;</span> Location: http://server_redirect/large_file.txt
<span class="pl-k">&lt;</span> 
<span class="pl-k">*</span> Closing connection 0
<span class="pl-k">*</span> Issue another request to this URL: <span class="pl-s"><span class="pl-pds">'</span>http://server_redirect/large_file.txt<span class="pl-pds">'</span></span>
<span class="pl-k">*</span> About to <span class="pl-en">connect</span>() to server_redirect port 443 (<span class="pl-c"><span class="pl-c">#</span>1)</span>
<span class="pl-k">*</span>   Trying ADDRESS...
<span class="pl-k">*</span> Connected to server_redirect (ADDRESS) port 443 (<span class="pl-c"><span class="pl-c">#</span>1)</span>
<span class="pl-k">&gt;</span> PUT /server_redirect/large_file.txt HTTP/1.1
<span class="pl-k">&gt;</span> User-Agent: curl/7.29.0
<span class="pl-k">&gt;</span> Host: server_redirect:443
<span class="pl-k">&gt;</span> Accept: <span class="pl-k">*</span>/<span class="pl-k">*</span>
<span class="pl-k">&gt;</span> Content-Length: 1048576
<span class="pl-k">&gt;</span> Expect: 100-continue
<span class="pl-k">&gt;</span> 
<span class="pl-k">&lt;</span> HTTP/1.1 100 Continue
<span class="pl-k">&lt;</span> Connection: Close
<span class="pl-k">&lt;</span> Server: OURSERVER
<span class="pl-k">&lt;</span> Date: Tue, 20 Dec 2022 14:34:33 GMT
<span class="pl-k">*</span> We are completely uploaded and fine
<span class="pl-k">&lt;</span> HTTP/1.1 201 CREATED
<span class="pl-k">&lt;</span> Connection: Keep-Alive
<span class="pl-k">&lt;</span> Server: OURSERVER
<span class="pl-k">&lt;</span> Content-Length: 0</pre></div>
<h2 dir="auto">System Information</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python -m requests.help"><pre class="notranslate"><code class="notranslate">$ python -m requests.help
</code></pre></div>
<p dir="auto">This (older) version silently works:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: &quot;4.0.0&quot;
  },
  &quot;charset_normalizer&quot;: {
    &quot;version&quot;: &quot;2.0.12&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;&quot;
  },
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;2.10&quot;
  },
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;,
    &quot;version&quot;: &quot;3.7.9&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;22.1.0&quot;,
    &quot;system&quot;: &quot;Darwin&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;&quot;,
    &quot;version&quot;: null
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.27.1&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;1010113f&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.26.3&quot;
  },
  &quot;using_charset_normalizer&quot;: false,
  &quot;using_pyopenssl&quot;: false
}"><pre class="notranslate">{
  <span class="pl-ent">"chardet"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>4.0.0<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"charset_normalizer"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.12<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"cryptography"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"idna"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.10<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"implementation"</span>: {
    <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>CPython<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.7.9<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"platform"</span>: {
    <span class="pl-ent">"release"</span>: <span class="pl-s"><span class="pl-pds">"</span>22.1.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"system"</span>: <span class="pl-s"><span class="pl-pds">"</span>Darwin<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"pyOpenSSL"</span>: {
    <span class="pl-ent">"openssl_version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"requests"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.27.1<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"system_ssl"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1010113f<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"urllib3"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.26.3<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"using_charset_normalizer"</span>: <span class="pl-c1">false</span>,
  <span class="pl-ent">"using_pyopenssl"</span>: <span class="pl-c1">false</span>
}</pre></div>
<p dir="auto">This version breaks (correctly):</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: null
  },
  &quot;charset_normalizer&quot;: {
    &quot;version&quot;: &quot;2.1.1&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;&quot;
  },
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;3.4&quot;
  },
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;,
    &quot;version&quot;: &quot;3.10.6&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;22.1.0&quot;,
    &quot;system&quot;: &quot;Darwin&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;&quot;,
    &quot;version&quot;: null
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.28.1&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;1010113f&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.26.13&quot;
  },
  &quot;using_charset_normalizer&quot;: true,
  &quot;using_pyopenssl&quot;: false
}"><pre class="notranslate">{
  <span class="pl-ent">"chardet"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"charset_normalizer"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.1.1<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"cryptography"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"idna"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.4<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"implementation"</span>: {
    <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>CPython<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.10.6<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"platform"</span>: {
    <span class="pl-ent">"release"</span>: <span class="pl-s"><span class="pl-pds">"</span>22.1.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"system"</span>: <span class="pl-s"><span class="pl-pds">"</span>Darwin<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"pyOpenSSL"</span>: {
    <span class="pl-ent">"openssl_version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"requests"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.28.1<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"system_ssl"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1010113f<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"urllib3"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.26.13<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"using_charset_normalizer"</span>: <span class="pl-c1">true</span>,
  <span class="pl-ent">"using_pyopenssl"</span>: <span class="pl-c1">false</span>
}</pre></div>