本文整理汇总了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)