I have a python script that should download some files from nexus3 server. Downloading code was working for a few months, but stopped working at some point. I tracked down the problem and come to the function that should download the file. It use requests library like this
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> url = 'http://my.server/repository/central-services/repo/artifact/maven-metadata.xml'
>>> url
'http://my.server/repository/central-services/repo/artifact/maven-metadata.xml'
>>> response = requests.get(url, stream=True)
>>> response.status_code
200
so far so good. At this point my function would download the file. As the file in general may be quite big, so I would use streaming mode via read() calls by reading 16kb chunks, but in this example I call just read():
>>> response.raw.read()
b''
Surprisingly, there is no data read, although there was definitely a content.
>>> response.headers['Content-Length']
'416'
Surprisingly I found my content in response.content field. I need a generic download() function, that would return stream-like object, rather than implicitly download the content to response.content field.
Are there any ideas?