def test_invalid_object_metadata(self):
    metadata = FDSObjectMetadata()

    metadata.add_user_metadata(FDSObjectMetadata.USER_DEFINED_METADATA_PREFIX
                               + "test", "test-value")
    metadata.add_header(Common.CACHE_CONTROL, "no-cache")

    try:
      metadata.add_user_metadata("test-key", "test-vale")
      self.fail("Exception should not be thrown here")
    except:
      pass
Example #2
0
def parse_metadata_from_str(metadata):
    fds_metadata = None
    if metadata:
        fds_metadata = FDSObjectMetadata()
        for i in metadata.split(';'):
            key, value = i.split(':', 1)
            if key and value:
                if key.startswith(FDSObjectMetadata.USER_DEFINED_METADATA_PREFIX):
                    fds_metadata.add_user_metadata(key, value)
                else:
                    fds_metadata.add_header(key, value)
    return fds_metadata
Example #3
0
def parse_metadata_from_str(metadata):
  fds_metadata = None
  if metadata:
    fds_metadata = FDSObjectMetadata()
    for i in metadata.split(';'):
      key, value = i.split(':', 1)
      if key and value:
        if key.startswith(FDSObjectMetadata.USER_DEFINED_METADATA_PREFIX):
          fds_metadata.add_user_metadata(key, value)
        else:
          fds_metadata.add_header(key, value)
  return fds_metadata
  def test_invalid_object_metadata(self):
    metadata = FDSObjectMetadata()

    metadata.add_user_metadata(FDSObjectMetadata.USER_DEFINED_METADATA_PREFIX
                        + "test", "test-value")
    metadata.add_header(Common.CACHE_CONTROL, "no-cache")

    try:
      metadata.add_user_metadata("test-key", "test-vale")
      self.fail("Exception should not be thrown here")
    except:
      pass
 def _parse_object_metadata_from_headers(self, response_headers):
   '''
   Parse object metadata from the response headers.
   '''
   metadata = FDSObjectMetadata()
   header_keys = [c.lower() for c in response_headers.keys()];
   for key in FDSObjectMetadata.PRE_DEFINED_METADATA:
     if key.lower() in header_keys:
       metadata.add_header(key, response_headers[key])
   for key in response_headers:
     if key.lower().startswith(FDSObjectMetadata.USER_DEFINED_METADATA_PREFIX):
       metadata.add_user_metadata(key, response_headers[key])
   return metadata