Exemplo n.º 1
0
def send_manifest(env, method, path, logger, extra_header, get_body=False,
                   query_string=None):
    """
    Use this method to send header against a resource already exist.
    """

    # Create a new Request
    req = Request(env)
    ssl = True if req.scheme.lower() == 'https' else False

    # Fixup the auth token, for some reason, the auth token padded the user
    # account at the front with a comma. We need to get rid of it, otherwise,
    # the auth token will be considered invalid.
    key, sep, value = req.headers[Consts.AUTH_TOKEN].partition(',')
    headers = {}
    headers[Consts.AUTH_TOKEN] = value if value != '' else key
    headers['Content-Length'] = '0'
    extra_header.update(headers)
    path = path.rstrip('/')

    if ssl:
        conn = HTTPSConnection('%s:%s' % (req.server_name,
                                          req.server_portport))
    else:
        conn = BufferedHTTPConnection('%s:%s' % (req.server_name,
                                                 req.server_port))

    conn.request('PUT', path, '', extra_header)

    res = conn.getresponse()

    return res