Reviewers: tkaitchuck, huebsch_google.com,
Description:
Makes cloudstorage_test.CloudStorageTest.testGzip and testStat tests of
appengine-gcs-client pass.
Fixes:
* https://code.google.com/p/googleappengine/issues/detail?id=9740
* https://code.google.com/p/appengine-gcs-client/issues/detail?id=14
Please review this at https://codereview.appspot.com/11802047/
Affected files:
M google/appengine/ext/cloudstorage/common.py
Index: google/appengine/ext/cloudstorage/common.py
===================================================================
--- google/appengine/ext/cloudstorage/common.py (revision 367)
+++ google/appengine/ext/cloudstorage/common.py (working copy)
@@ -76,8 +76,11 @@
_GCS_BUCKET_REGEX = re.compile(_GCS_BUCKET_REGEX_BASE + r'$')
_GCS_BUCKET_PATH_REGEX = re.compile(r'/' + _GCS_BUCKET_REGEX_BASE + r'$')
_GCS_FULLPATH_REGEX = re.compile(r'/' + _GCS_BUCKET_REGEX_BASE + r'/.*')
-_GCS_OPTIONS = ('x-goog-acl',
- 'x-goog-meta-')
+_GCS_METADATA = ['x-goog-meta-',
+ 'content-disposition',
+ 'cache-control',
+ 'content-encoding']
+_GCS_OPTIONS = _GCS_METADATA + ['x-goog-acl']
CS_XML_NS = 'http://doc.s3.amazonaws.com/2006-03-01'
@@ -128,8 +131,9 @@
etag: hex digest of the md5 hash of the file's content. str.
st_ctime: posix file creation time. float compatible.
content_type: content type. str.
- metadata: a str->str dict of user specified metadata from the
- x-goog-meta header, e.g. {'x-goog-meta-foo': 'foo'}.
+ metadata: a str->str dict of user specified options when creating
+ the file. Possible keys are x-goog-meta-, content-disposition,
+ content-encoding, and cache-control.
"""
self.filename = filename
self.st_size = long(st_size)
@@ -159,9 +163,9 @@
def get_metadata(headers):
- """Get user defined metadata from HTTP response headers."""
+ """Get user defined options from HTTP response headers."""
return dict((k, v) for k, v in headers.iteritems()
- if k.startswith('x-goog-meta-'))
+ if any(k.lower().startswith(valid) for valid in
_GCS_METADATA))
def validate_bucket_name(name):
@@ -244,7 +248,7 @@
for k, v in options.iteritems():
if not isinstance(k, str):
raise TypeError('option %r should be a str.' % k)
- if not any(k.startswith(valid) for valid in _GCS_OPTIONS):
+ if not any(k.lower().startswith(valid) for valid in _GCS_OPTIONS):
raise ValueError('option %s is not supported.' % k)
if not isinstance(v, basestring):
raise TypeError('value %r for option %s should be of type
basestring.' %
--
You received this message because you are subscribed to the Google Groups "Google
App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.