mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Improve parsing of 'unix://' addresses in parse_address (#1623)
This commit is contained in:
parent
e868c52997
commit
81efa40da7
@ -21,6 +21,7 @@ import inspect
|
|||||||
import errno
|
import errno
|
||||||
import warnings
|
import warnings
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
from gunicorn import _compat
|
from gunicorn import _compat
|
||||||
from gunicorn.errors import AppImportError
|
from gunicorn.errors import AppImportError
|
||||||
@ -232,11 +233,8 @@ def is_ipv6(addr):
|
|||||||
|
|
||||||
|
|
||||||
def parse_address(netloc, default_port=8000):
|
def parse_address(netloc, default_port=8000):
|
||||||
if netloc.startswith("unix://"):
|
if re.match(r'unix:(//)?', netloc):
|
||||||
return netloc.split("unix://")[1]
|
return re.split(r'unix:(//)?', netloc)[-1]
|
||||||
|
|
||||||
if netloc.startswith("unix:"):
|
|
||||||
return netloc.split("unix:")[1]
|
|
||||||
|
|
||||||
if netloc.startswith("tcp://"):
|
if netloc.startswith("tcp://"):
|
||||||
netloc = netloc.split("tcp://")[1]
|
netloc = netloc.split("tcp://")[1]
|
||||||
|
|||||||
12
tests/test_util.py
Normal file
12
tests/test_util.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# -*- coding: utf-8 -
|
||||||
|
#
|
||||||
|
# This file is part of gunicorn released under the MIT license.
|
||||||
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
|
from gunicorn import util
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_address():
|
||||||
|
# Test unix socket addresses (PR #1623)
|
||||||
|
assert util.parse_address('unix://var/run/test.sock') == 'var/run/test.sock'
|
||||||
|
assert util.parse_address('unix:/var/run/test.sock') == '/var/run/test.sock'
|
||||||
Loading…
x
Reference in New Issue
Block a user