<p dir="auto">Hi,</p>
<p dir="auto">I'm trying to upload a file that weight about 3GB and I'm getting the following error:<br>
"OverflowError: string longer than 2147483647 bytes"</p>
<p dir="auto">If I understand correctly it seems like there's a 2GB limit? didnt manage to find any reference to such limiation or how to bypass it (if possible).</p>
<p dir="auto">The code i'm using is:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
datafile = 'someHugeFile'
with open(datafile, 'rb') as myfile:
    args = myfile.read()
resp = requests.put(url, data=args, verify=False)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/api.py&quot;, line 99, in put
    return request('put', url, data=data, **kwargs)
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/api.py&quot;, line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/sessions.py&quot;, line 456, in request
    resp = self.send(prep, **send_kwargs)
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/sessions.py&quot;, line 559, in send
    r = adapter.send(request, **kwargs)
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/adapters.py&quot;, line 327, in send
    timeout=timeout
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py&quot;, line 493, in urlopen
    body=body, headers=headers)
  File &quot;/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py&quot;, line 291, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File &quot;/usr/local/lib/python2.7/httplib.py&quot;, line 995, in request
    self._send_request(method, url, body, headers)
  File &quot;/usr/local/lib/python2.7/httplib.py&quot;, line 1029, in _send_request
    self.endheaders(body)
  File &quot;/usr/local/lib/python2.7/httplib.py&quot;, line 991, in endheaders
    self._send_output(message_body)
  File &quot;/usr/local/lib/python2.7/httplib.py&quot;, line 844, in _send_output
    self.send(msg)
  File &quot;/usr/local/lib/python2.7/httplib.py&quot;, line 820, in send
    self.sock.sendall(data)
  File &quot;/usr/local/lib/python2.7/ssl.py&quot;, line 234, in sendall
    v = self.send(data[count:])
  File &quot;/usr/local/lib/python2.7/ssl.py&quot;, line 203, in send
    v = self._sslobj.write(data)
OverflowError: string longer than 2147483647 bytes"><pre class="notranslate"><span class="pl-s1">datafile</span> <span class="pl-c1">=</span> <span class="pl-s">'someHugeFile'</span>
<span class="pl-k">with</span> <span class="pl-en">open</span>(<span class="pl-s1">datafile</span>, <span class="pl-s">'rb'</span>) <span class="pl-k">as</span> <span class="pl-s1">myfile</span>:
    <span class="pl-s1">args</span> <span class="pl-c1">=</span> <span class="pl-s1">myfile</span>.<span class="pl-en">read</span>()
<span class="pl-s1">resp</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">put</span>(<span class="pl-s1">url</span>, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">args</span>, <span class="pl-s1">verify</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"&lt;stdin&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/api.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">99</span>, <span class="pl-s1">in</span> <span class="pl-s1">put</span>
    <span class="pl-k">return</span> <span class="pl-en">request</span>(<span class="pl-s">'put'</span>, <span class="pl-s1">url</span>, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">data</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/api.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">44</span>, <span class="pl-s1">in</span> <span class="pl-s1">request</span>
    <span class="pl-k">return</span> <span class="pl-s1">session</span>.<span class="pl-en">request</span>(<span class="pl-s1">method</span><span class="pl-c1">=</span><span class="pl-s1">method</span>, <span class="pl-s1">url</span><span class="pl-c1">=</span><span class="pl-s1">url</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/sessions.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">456</span>, <span class="pl-s1">in</span> <span class="pl-s1">request</span>
    <span class="pl-s1">resp</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">send</span>(<span class="pl-s1">prep</span>, <span class="pl-c1">**</span><span class="pl-s1">send_kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/sessions.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">559</span>, <span class="pl-s1">in</span> <span class="pl-s1">send</span>
    <span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">adapter</span>.<span class="pl-en">send</span>(<span class="pl-s1">request</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/adapters.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">327</span>, <span class="pl-s1">in</span> <span class="pl-s1">send</span>
    <span class="pl-s1">timeout</span><span class="pl-c1">=</span><span class="pl-s1">timeout</span>
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">493</span>, <span class="pl-s1">in</span> <span class="pl-s1">urlopen</span>
    <span class="pl-s1">body</span><span class="pl-c1">=</span><span class="pl-s1">body</span>, <span class="pl-s1">headers</span><span class="pl-c1">=</span><span class="pl-s1">headers</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">291</span>, <span class="pl-s1">in</span> <span class="pl-s1">_make_request</span>
    <span class="pl-s1">conn</span>.<span class="pl-en">request</span>(<span class="pl-s1">method</span>, <span class="pl-s1">url</span>, <span class="pl-c1">**</span><span class="pl-s1">httplib_request_kw</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/httplib.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">995</span>, <span class="pl-s1">in</span> <span class="pl-s1">request</span>
    <span class="pl-s1">self</span>.<span class="pl-en">_send_request</span>(<span class="pl-s1">method</span>, <span class="pl-s1">url</span>, <span class="pl-s1">body</span>, <span class="pl-s1">headers</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/httplib.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1029</span>, <span class="pl-s1">in</span> <span class="pl-s1">_send_request</span>
    <span class="pl-s1">self</span>.<span class="pl-en">endheaders</span>(<span class="pl-s1">body</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/httplib.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">991</span>, <span class="pl-s1">in</span> <span class="pl-s1">endheaders</span>
    <span class="pl-s1">self</span>.<span class="pl-en">_send_output</span>(<span class="pl-s1">message_body</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/httplib.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">844</span>, <span class="pl-s1">in</span> <span class="pl-s1">_send_output</span>
    <span class="pl-s1">self</span>.<span class="pl-en">send</span>(<span class="pl-s1">msg</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/httplib.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">820</span>, <span class="pl-s1">in</span> <span class="pl-s1">send</span>
    <span class="pl-s1">self</span>.<span class="pl-s1">sock</span>.<span class="pl-en">sendall</span>(<span class="pl-s1">data</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/ssl.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">234</span>, <span class="pl-s1">in</span> <span class="pl-s1">sendall</span>
    <span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">send</span>(<span class="pl-s1">data</span>[<span class="pl-s1">count</span>:])
  <span class="pl-v">File</span> <span class="pl-s">"/usr/local/lib/python2.7/ssl.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">203</span>, <span class="pl-s1">in</span> <span class="pl-s1">send</span>
    <span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">_sslobj</span>.<span class="pl-en">write</span>(<span class="pl-s1">data</span>)
<span class="pl-v">OverflowError</span>: <span class="pl-s1">string</span> <span class="pl-s1">longer</span> <span class="pl-s1">than</span> <span class="pl-c1">2147483647</span> <span class="pl-s1">bytes</span></pre></div>
<p dir="auto">For smaller files this code works fine for me.</p>
<p dir="auto">Summary.</p>
<p dir="auto">When creating a session and setting <code class="notranslate">verify=False</code> with a proxy defined value error is raised.  The easiest way to setup this issue is to open Fiddler4 and run the following on Windows:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import requests
import urllib
url = &quot;https://www.arcgis.com/sharing/rest?f=json&quot;
proxies = urllib.request.getproxies()

session = requests.Session()
session.proxies = proxies
session.trust_env = True
session.verify = False
resp = session.get(url=url)
print(resp.json())
"><pre class="notranslate"><code class="notranslate">import requests
import urllib
url = "https://www.arcgis.com/sharing/rest?f=json"
proxies = urllib.request.getproxies()

session = requests.Session()
session.proxies = proxies
session.trust_env = True
session.verify = False
resp = session.get(url=url)
print(resp.json())

</code></pre></div>
<h2 dir="auto">Expected Result</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{'currentVersion': '9.2'}"><pre class="notranslate"><code class="notranslate">{'currentVersion': '9.2'}
</code></pre></div>
<h2 dir="auto">Actual Result</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  Python Shell, prompt 2, line 10
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py&quot;, line 555, in get
    return self.request('GET', url, **kwargs)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py&quot;, line 542, in request
    resp = self.send(prep, **send_kwargs)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py&quot;, line 655, in send
    r = adapter.send(request, **kwargs)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\adapters.py&quot;, line 449, in send
    timeout=timeout
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connectionpool.py&quot;, line 696, in urlopen
    self._prepare_proxy(conn)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connectionpool.py&quot;, line 964, in _prepare_proxy
    conn.connect()
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connection.py&quot;, line 359, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connection.py&quot;, line 506, in _connect_tls_proxy
    ssl_context=ssl_context,
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\util\ssl_.py&quot;, line 432, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\util\ssl_.py&quot;, line 474, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\ssl.py&quot;, line 423, in wrap_socket
    session=session
  File &quot;C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\ssl.py&quot;, line 827, in _create
    raise ValueError(&quot;check_hostname requires server_hostname&quot;)
builtins.ValueError: check_hostname requires server_hostname"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  Python Shell, prompt 2, line 10
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
    self._prepare_proxy(conn)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
    conn.connect()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connection.py", line 359, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\connection.py", line 506, in _connect_tls_proxy
    ssl_context=ssl_context,
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\util\ssl_.py", line 432, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\site-packages\urllib3\util\ssl_.py", line 474, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\ssl.py", line 423, in wrap_socket
    session=session
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-dev\Lib\ssl.py", line 827, in _create
    raise ValueError("check_hostname requires server_hostname")
builtins.ValueError: check_hostname requires server_hostname
</code></pre></div>
<p dir="auto">What happened instead.</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
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">requests</span></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>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: &quot;4.0.0&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;3.3.1&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.10&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;10&quot;,
    &quot;system&quot;: &quot;Windows&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;1010109f&quot;,
    &quot;version&quot;: &quot;20.0.1&quot;
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.25.1&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;1010109f&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.25.11&quot;
  },
  &quot;using_pyopenssl&quot;: true
}"><pre class="notranslate"><code class="notranslate">{
  "chardet": {
    "version": "4.0.0"
  },
  "cryptography": {
    "version": "3.3.1"
  },
  "idna": {
    "version": "2.10"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.10"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "1010109f",
    "version": "20.0.1"
  },
  "requests": {
    "version": "2.25.1"
  },
  "system_ssl": {
    "version": "1010109f"
  },
  "urllib3": {
    "version": "1.25.11"
  },
  "using_pyopenssl": true
}
</code></pre></div>