Example #1
0
File: util.py Project: m42e/pb
def get_host_name(request):
    if not request:
        return
    host = get_host(request.environ)
    if host:
        host = host.split(':')[0]
        return host
Example #2
0
def get_host_name(request):
    if not request:
        return
    host = get_host(request.environ)
    if host:
        host = host.split(':')[0]
        return host
Example #3
0
File: cache.py Project: GermainZ/pb
def invalidate(url):

    base = current_app.config.get('VARNISH_BASE')
    if not base:
        return
    s = get_session()

    url = urlsplit(url).path
    url = path.splitext(url.split('/')[1])[0]
    url = urljoin(base, '/.*{}.*'.format(url))
    headers = {'Host': get_host(request.environ)}

    return s.executor.submit(s.request, 'BAN', url, headers=headers)
Example #4
0
def invalidate(uuid):
    cur = model.get_meta(_id=uuid.hex)
    if not cur or not cur.count():
        return
    paste = cur.__next__()

    base = current_app.config.get('VARNISH_BASE')
    if not base:
        return paste

    s = get_session()

    for url in all_urls(paste):
        url = urljoin(base, '/.*{}.*'.format(url))
        headers = {'Host': get_host(request.environ)}
        s.executor.submit(s.request, 'BAN', url, headers=headers)

    return paste
Example #5
0
File: cache.py Project: ptpb/pb
def invalidate(**kwargs):
    cur = model.get_meta(**kwargs)
    try:
        paste = next(cur)
    except StopIteration:
        return

    base = current_app.config.get('VARNISH_BASE')
    if not base:
        return paste

    s = get_session()

    for url in all_urls(paste):
        url = urljoin(base, '/.*{}.*'.format(url))
        headers = {'Host': get_host(request.environ)}
        s.executor.submit(s.request, 'BAN', url, headers=headers)

    return paste
Example #6
0
def invalidate(**kwargs):
    cur = model.get_meta(**kwargs)
    try:
        paste = next(cur)
    except StopIteration:
        return

    base = current_app.config.get('VARNISH_BASE')
    if not base:
        return paste

    s = get_session()

    for url in all_urls(paste):
        url = urljoin(base, '/.*{}.*'.format(url))
        headers = {'Host': get_host(request.environ)}
        s.executor.submit(s.request, 'BAN', url, headers=headers)

    return paste