本文整理匯總了Python中http.server.SimpleHTTPRequestHandler.parse_request方法的典型用法代碼示例。如果您正苦於以下問題:Python SimpleHTTPRequestHandler.parse_request方法的具體用法?Python SimpleHTTPRequestHandler.parse_request怎麽用?Python SimpleHTTPRequestHandler.parse_request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http.server.SimpleHTTPRequestHandler
的用法示例。
在下文中一共展示了SimpleHTTPRequestHandler.parse_request方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: parse_request
# 需要導入模塊: from http.server import SimpleHTTPRequestHandler [as 別名]
# 或者: from http.server.SimpleHTTPRequestHandler import parse_request [as 別名]
def parse_request(self):
if not SimpleHTTPRequestHandler.parse_request(self):
return False
host, port, resource = http_header_util.parse_uri(self.path)
print 'Got ' + self.path #FIXME
if resource is None:
self._logger.info('WS Invalid URI: %r', self.path)
self._logger.info('WS Fallback to normal HTTP.')
return True
if (not self.permissive and (host is None or self.origin is None or
host.startswith('file://') or
host != self.origin)) or \
(self.permissive and host is not None and
self.origin is not None and
not host.startswith('file://') and host != self.origin):
self._logger.info('WS Invalid host: %r (expected: %r)',
host, self.origin)
self._logger.info('WS Fallback to normal HTTP.')
return True
if port is not None and self.port is not None and port != self.port:
self._logger.info('WS Invalid port: %r (expected: %r)',
port, self.port)
self._logger.info('WS Fallback to normal HTTP.')
return True
self.path = resource
return self.handle_ws(resource)