[Python-Dev] Can ftp url start with file:// ? (original) (raw)

Bill Janssen janssen at parc.com
Fri Jul 9 18:41:49 CEST 2010


Senthil Kumaran <orsenthil at gmail.com> wrote:

On Fri, Jul 09, 2010 at 02:23:40PM +1000, Steven D'Aprano wrote: > > Is this is valid ftp url? > > > > # file://ftp.example.com/blah.txt (an ftp URL) > > > > My answer is no. When we have the scheme specifically mentioned as > > file:// it is no point in considering it as ftp url (which should > > start with ftp://). > > I agree. Just because the host is called ftp doesn't mean you should > use the ftp protocol to get the file.

It was not just for the host being called ftp.example.com It was for a pattern that file:/// is local file (correct) and file://localhost/somepath is again local file (correct again) but file://anyhost.domain/file.txt is actually ftp (pretty weird).

RFC 1738 explicitly says that "<file://>/" is pretty much useless for anything except host=localhost:

``The file URL scheme is unusual in that it does not specify an Internet protocol or access method for such files; as such, its utility in network protocols between hosts is limited.''

So, FTP is not the "default protocol". On the other hand, if actually begins with "ftp.", it's a pretty good guess that FTP will work. Similarly, if actually begins with "www.", it's a pretty good guess that HTTP will work. This seems to me like a practicality-vs.-purity consideration.

Bill



More information about the Python-Dev mailing list