>>> s = requests.Session()
>>> resp = s.list("ftp://mirrors.ibiblio.org/", auth=("anonymous", "me@anonymous.com",))
This fails:
>>> resp = s.list("ftp://mirrors.ibiblio.org", auth=("anonymous", "me@anonymous.com",))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\test\lib\site-packages\requests_ftp\ftp.py", line 21, in list_helper
return self.request('LIST', url, **kwargs)
File "c:\test\lib\site-packages\requests\sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "c:\test\lib\site-packages\requests\sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "c:\test\lib\site-packages\requests_ftp\ftp.py", line 145, in send
host, port, path = self.get_host_and_path_from_url(request)
File "c:\test\lib\site-packages\requests_ftp\ftp.py", line 288, in get_host_and_path_from_url
if path[0] == '/':
IndexError: string index out of range
It is probably best to test with startswith rather than a string index or to check if the string exists or else ;)
This works:
This fails:
It is probably best to test with startswith rather than a string index or to check if the string exists or else ;)