本文整理匯總了Python中gunicorn._compat.urlsplit方法的典型用法代碼示例。如果您正苦於以下問題:Python _compat.urlsplit方法的具體用法?Python _compat.urlsplit怎麽用?Python _compat.urlsplit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gunicorn._compat
的用法示例。
在下文中一共展示了_compat.urlsplit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse_request_line
# 需要導入模塊: from gunicorn import _compat [as 別名]
# 或者: from gunicorn._compat import urlsplit [as 別名]
def parse_request_line(self, line):
bits = line.split(None, 2)
if len(bits) != 3:
raise InvalidRequestLine(line)
# Method
if not METH_RE.match(bits[0]):
raise InvalidRequestMethod(bits[0])
self.method = bits[0].upper()
# URI
# When the path starts with //, urlsplit considers it as a
# relative uri while the RDF says it shouldnt
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
# considers it as an absolute url.
# fix issue #297
if bits[1].startswith("//"):
self.uri = bits[1][1:]
else:
self.uri = bits[1]
try:
parts = urlsplit(self.uri)
except ValueError:
raise InvalidRequestLine(line)
self.path = parts.path or ""
self.query = parts.query or ""
self.fragment = parts.fragment or ""
# Version
match = VERSION_RE.match(bits[2])
if match is None:
raise InvalidHTTPVersion(bits[2])
self.version = (int(match.group(1)), int(match.group(2)))