Added getinfo function to HTTPFS (returns HTTP headers)

parent 82887d81
......@@ -9,6 +9,7 @@ from fs.base import FS
from fs.path import normpath
from fs.errors import ResourceNotFoundError, UnsupportedError
from urllib2 import urlopen, URLError
from datetime import datetime
from fs.filelike import FileWrapper
class HTTPFS(FS):
......@@ -79,3 +80,13 @@ class HTTPFS(FS):
dirs_only=False,
files_only=False):
return []
def getinfo(self, path):
url = self._make_url(path)
info = urlopen(url).info().dict
if 'content-length' in info:
info['size'] = info['content-length']
if 'last-modified' in info:
info['modified_time'] = datetime.strptime(info['last-modified'],
"%a, %d %b %Y %H:%M:%S %Z")
return info
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment