Cannot Upload a large package on Windows 7 32 bit OS, with requests

Cannot Upload from a Windows 7 32 bit OS. It works fine on Windows 7 64 bit OS with 32/64 bit Python.
I am using Python 3.4.3 with latest requests API.


This is likely a duplicate of https://github.com/kennethreitz/requests/issues/2510 (in the sense that you're reading the exception improperly) and you've given us no detail on what you're code does or what the _full_ traceback is.

Please post questions to [StackOverflow](https://stackoverflow.com/questions/tagged/python-requests) if you intend to ask questions.


Sorry I couldn't provide you more details earlier.

The error I get is

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 376, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 559, in urlopen
    body=body, headers=headers)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 378, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python34\lib\http\client.py", line 1171, in getresponse
    response.begin()
  File "C:\Python34\lib\http\client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "C:\Python34\lib\http\client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python34\lib\socket.py", line 374, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly close
d by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 370, in send
    timeout=timeout
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\retry.py",
line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py"
, line 309, in reraise
    raise value.with_traceback(tb)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 559, in urlopen
    body=body, headers=headers)
  File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.p
y", line 378, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Python34\lib\http\client.py", line 1171, in getresponse
    response.begin()
  File "C:\Python34\lib\http\client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "C:\Python34\lib\http\client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Python34\lib\socket.py", line 374, in readinto
    return self._sock.recv_into(b)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', Conn
ectionResetError(10054, 'An existing connection was forcibly closed by the remot
e host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Upgrader.py", line 12, in <module>
    rdst = requests.post(urldst, files={'1_19_0_developer.exe': resp.content})
  File "C:\Python34\lib\site-packages\requests\api.py", line 109, in post
    return request('post', url, data=data, json=json, *_kwargs)
  File "C:\Python34\lib\site-packages\requests\api.py", line 50, in request
    response = session.request(method=method, url=url, *_kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 468, in reques
t
    resp = self.send(prep, *_send_kwargs)
  File "C:\Python34\lib\site-packages\requests\sessions.py", line 576, in send
    r = adapter.send(request, *_kwargs)
  File "C:\Python34\lib\site-packages\requests\adapters.py", line 412, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetErro
r(10054, 'An existing connection was forcibly closed by the remote host', None,
10054, None))


The code is

import requests
from requests_file import FileAdapter

s = requests.Session()
s.mount('file://', FileAdapter())
resp = s.get('file:///local_package_name')
urldst = 'Upload URL'
rdst = requests.post(urldst, files={'filename': resp.content})
print(rdst)

This code works fine on a Windows7 64 bit OS, but returns the error as described in Windows7 32 bit OS.


So the actual problem here is that the remote peer is closing the connection. It appears not to like the request you're making on your 32-bit machine. My suspicion here is that you're sending an incomplete request from resp.content.

Out of interest, why are you tripping this through a file adapter instead of just sending that file directly? 


Thanks for your reply.
I am using File Adapter to Upload a package from a local drive.(local_package_name is an input path for the local package on a C Drive).

I couldn't upload the file directly, without using FileAdapter.
I get the following error, if I upload file directly.

Traceback (most recent call last):
  File "Upgrader.py", line 12, in <module>
    resp = s.get('file:///C:/pythonws/1_9_0.exe')
  File "C:\Python341\lib\site-packages\requests\sessions.py", line 480, in get
    return self.request('GET', url, *_kwargs)
  File "C:\Python341\lib\site-packages\requests\sessions.py", line 468, in reque
st
    resp = self.send(prep, *_send_kwargs)
  File "C:\Python341\lib\site-packages\requests\sessions.py", line 570, in send
    adapter = self.get_adapter(url=request.url)
  File "C:\Python341\lib\site-packages\requests\sessions.py", line 644, in get_a
dapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'file:/
//C:/pythonws/1_9_0.exe'

Please suggest about the changes that should be made to resp.content to make it work on a 32 bit Windows 7 OS.

Thanks.


Also, I can upload small packages using the provided code on a 32 bit Windows 7 OS.
The only problem is with uploading large packages.


Are you uploading over HTTPS or HTTP?


Uploading over HTTP.
The code works on the same setup, but using 64 bit Windows OS and also smaller files in 32 bit Windows OS.


If you're uploading over HTTP, can you use something like Wireshark to capture the headers on each machine and put them here? Feel free to remove the Authorization header if it's present.