Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file:// protocol not available #2732

Closed
Moliholy opened this issue Aug 19, 2015 · 2 comments
Closed

file:// protocol not available #2732

Moliholy opened this issue Aug 19, 2015 · 2 comments

Comments

@Moliholy
Copy link

Hello all, and first of all thanks for this awesome library.

While working with requests I was surprised to find out that it doesn't handle the file:// protocol. Even though I understand it's maybe not a key feature of this library it would come in handy for compatibility reasons.

Concretely I have sort of a 'Fetcher' class that servers files from a 'Repository', but this repository can be local or remote. In case of being local I tried (unsuccessfully, of course) to use the file:// protocol. Finally it forced me to considerably increase the number of lines of code I needed to handle the issue.

For example, something like this would be fine:

response = requests.get('file:///Users/User/my_file.txt')

So far it raises this exception:

  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 649, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'file:///Users/User/my_file.txt'

My questions are:

  1. Would there be a reason to not to implement this feature?
  2. In case there isn't, shall I submit a a pull request, or it is already planned to add this functionality soon?
@Lukasa
Copy link
Member

Lukasa commented Aug 19, 2015

Thanks for this issue!

The reason we don't support the file:// protocol is because requests is a HTTP library. Our core purpose is to do HTTP: anything else is outside the scope of the core library.

I believe there is a pluggable Transport Adapter for the file protocol floating around. You can also consider adapting one from this answer.

@Lukasa Lukasa closed this as completed Aug 19, 2015
@sigmavirus24
Copy link
Contributor

Before opening issues, please search all issues (not just open ones) for similar issues. This is just the earliest issue I could find and there are several others (including pull requests).

openstack-gerrit pushed a commit to openstack/goal-tools that referenced this issue Sep 5, 2018
The import-goal --project-list option currently only supports
URLs but the requests library doesn't support the file:// protocol:

  psf/requests#2732

This change adds the ability to read a file path for --project-list
instead of rely on URL in case you have a locally modified projects.yaml.

Change-Id: I584534fb32f42e5d78941637285623ad96cf79c3
Story: 2003653
Task: 26066
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants