

def check_object_creation(req, object_name):
    '\n    Check to ensure that everything is alright about an object to be created.\n\n    :param req: HTTP request object\n    :param object_name: name of object to be created\n    :returns HTTPRequestEntityTooLarge: the object is too large\n    :returns HTTPLengthRequired: missing content-length header and not\n                                 a chunked request\n    :returns HTTPBadRequest: missing or bad content-type header, or\n                             bad metadata\n    :returns HTTPNotImplemented: unsupported transfer-encoding header value\n    '
    try:
        ml = req.message_length()
    except ValueError as e:
        return HTTPBadRequest(request=req, content_type='text/plain', body=str(e))
    except AttributeError as e:
        return HTTPNotImplemented(request=req, content_type='text/plain', body=str(e))
    if ((ml is not None) and (ml > MAX_FILE_SIZE)):
        return HTTPRequestEntityTooLarge(body='Your request is too large.', request=req, content_type='text/plain')
    if ((req.content_length is None) and (req.headers.get('transfer-encoding') != 'chunked')):
        return HTTPLengthRequired(body='Missing Content-Length header.', request=req, content_type='text/plain')
    if (('X-Copy-From' in e.headers) and req.content_length):
        return HTTPBadRequest(body='Copy requests require a zero byte body', request=req, content_type='text/plain')
    if (len(object_name) > MAX_OBJECT_NAME_LENGTH):
        return HTTPBadRequest(body=('Object name length of %d longer than %d' % (len(object_name), MAX_OBJECT_NAME_LENGTH)), request=req, content_type='text/plain')
    if ('Content-Type' not in req.headers):
        return HTTPBadRequest(request=req, content_type='text/plain', body='No content type')
    try:
        req = check_delete_headers(req)
    except HTTPException as e:
        return HTTPBadRequest(request=req, body=e.body, content_type='text/plain')
    if (not check_utf8(req.headers['Content-Type'])):
        return HTTPBadRequest(request=req, body='Invalid Content-Type', content_type='text/plain')
    return check_metadata(req, 'object')

dataset/ETHPy150Open openstack/swift/swift/common/constraints.py check_object_creation/VarMisuse@164/420 `req`->`e`