Revision a6eb13e9 pithos/api/util.py

b/pithos/api/util.py
77 77
    """Get all prefix-* request headers in a dict. Reformat keys with format_meta_key()."""
78 78
    
79 79
    prefix = 'HTTP_' + prefix.upper().replace('-', '_')
80
    return dict([(format_meta_key(k[5:]), v) for k, v in request.META.iteritems() if k.startswith(prefix)])
80
    return dict([(format_meta_key(k[5:]), v) for k, v in request.META.iteritems() if k.startswith(prefix) and len(k) > len(prefix)])
81 81

  
82 82
def get_account_meta(request):
83 83
    """Get metadata from an account request."""
......
232 232
    
233 233
    meta = get_object_meta(request)
234 234
    permissions = get_sharing(request)
235
    src_version = request.META.get('HTTP_X_SOURCE_VERSION')
236
    
237
    try:
238
        if move:
239
            src_meta = backend.get_object_meta(request.user, v_account, src_container, src_name)
240
        else:
241
            src_meta = backend.get_object_meta(request.user, v_account, src_container, src_name, src_version)
242
    except NameError, IndexError:
243
        raise ItemNotFound('Container or object does not exist')
244
    
245
    # Keep previous values of 'Content-Type' (if a new one is absent) and 'hash'.
246
    if 'Content-Type' in meta and 'Content-Type' in src_meta:
247
        del(src_meta['Content-Type'])
248
    for k in ('Content-Type', 'hash'):
249
        if k in src_meta:
250
            meta[k] = src_meta[k]
251
    
235
    src_version = request.META.get('HTTP_X_SOURCE_VERSION')    
252 236
    try:
253 237
        if move:
254
            backend.move_object(request.user, v_account, src_container, src_name, dest_container, dest_name, meta, True, permissions)
238
            backend.move_object(request.user, v_account, src_container, src_name, dest_container, dest_name, meta, False, permissions)
255 239
        else:
256
            backend.copy_object(request.user, v_account, src_container, src_name, dest_container, dest_name, meta, True, permissions, src_version)
240
            backend.copy_object(request.user, v_account, src_container, src_name, dest_container, dest_name, meta, False, permissions, src_version)
257 241
    except NameError, IndexError:
258 242
        raise ItemNotFound('Container or object does not exist')
259 243
    except ValueError:

Also available in: Unified diff