def get_bucket_region()

in ext.py [0:0]


def get_bucket_region(url):
    # Get the headers for this bucket.
    # Verify=False because the wildcard matching doesn't work for buckets with '.'
    r = requests.head(url, verify=False)

    if r.status_code == requests.codes.not_found:
        return None

    if not "x-amz-bucket-region" in r.headers:
        print(r.headers)
        print("{} {} {}".format(r.status_code, r.reason, r.url))
        raise Exception("Bucket region missing from request header?")

    return r.headers["x-amz-bucket-region"]