diff options
author | Tim Burke <tim.burke@gmail.com> | 2015-12-08 10:45:07 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2016-04-08 16:57:51 -0700 |
commit | 9fd537a08245cf6a34c1abdf8b7c42bfd3669c74 (patch) | |
tree | 2e097bbcbb5e80a07f3a868818f90b62c32d1ef3 /swiftclient/service.py | |
parent | 015903e383a27318918ee7827574ecb120110ae2 (diff) | |
download | python-swiftclient-9fd537a08245cf6a34c1abdf8b7c42bfd3669c74.tar.gz |
Use application/directory content-type for dir markers
Previously, we were using a content-type of text/directory, but that is
already defined in RFC 2425 and doesn't reflect our usage:
The text/directory Content-Type is defined for holding a variety
of directory information, for example, name, or email address,
or logo.
(From there it goes on to describe a superset of the vCard format
defined in RFC 2426.)
application/directory, on the other hand, is used by Static Web [1] and
is used by cloudfuse [2]. Seems like as sane a choice as any to
standardize on.
[1] https://github.com/openstack/swift/blob/2.5.0/swift/common/middleware/staticweb.py#L71-L75
[2] https://github.com/redbo/cloudfuse/blob/1.0/README#L105-L106
Change-Id: I19e30484270886292d83f50e7ee997b6e1623ec7
Diffstat (limited to 'swiftclient/service.py')
-rw-r--r-- | swiftclient/service.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index 99c833e..232815f 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -189,6 +189,10 @@ _default_local_options = { } POLICY = 'X-Storage-Policy' +KNOWN_DIR_MARKERS = ( + 'application/directory', # Preferred + 'text/directory', # Historically relevant +) def get_from_queue(q, timeout=864000): @@ -1130,9 +1134,8 @@ class SwiftService(object): fp = None try: - content_type = headers.get('content-type') - if (content_type and - content_type.split(';', 1)[0] == 'text/directory'): + content_type = headers.get('content-type', '').split(';', 1)[0] + if content_type in KNOWN_DIR_MARKERS: make_dir = not no_file and out_file != "-" if make_dir and not isdir(path): mkdirs(path) @@ -1590,12 +1593,12 @@ class SwiftService(object): if options['changed']: try: headers = conn.head_object(container, obj) - ct = headers.get('content-type') + ct = headers.get('content-type', '').split(';', 1)[0] cl = int(headers.get('content-length')) et = headers.get('etag') mt = headers.get('x-object-meta-mtime') - if (ct.split(';', 1)[0] == 'text/directory' and + if (ct in KNOWN_DIR_MARKERS and cl == 0 and et == EMPTY_ETAG and mt == put_headers['x-object-meta-mtime']): @@ -1614,7 +1617,7 @@ class SwiftService(object): return res try: conn.put_object(container, obj, '', content_length=0, - content_type='text/directory', + content_type=KNOWN_DIR_MARKERS[0], headers=put_headers, response_dict=results_dict) res.update({ |