本文整理匯總了Python中http.HTTPStatus.REQUEST_URI_TOO_LONG屬性的典型用法代碼示例。如果您正苦於以下問題:Python HTTPStatus.REQUEST_URI_TOO_LONG屬性的具體用法?Python HTTPStatus.REQUEST_URI_TOO_LONG怎麽用?Python HTTPStatus.REQUEST_URI_TOO_LONG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類http.HTTPStatus
的用法示例。
在下文中一共展示了HTTPStatus.REQUEST_URI_TOO_LONG屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_one_request
# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import REQUEST_URI_TOO_LONG [as 別名]
def handle_one_request(self):
try:
self.raw_requestline = await self.rfile.readline()
if len(self.raw_requestline) > 65536:
self.requestline = ''
self.request_version = ''
self.command = ''
self.send_error(HTTPStatus.REQUEST_URI_TOO_LONG)
return
if not self.raw_requestline:
self.close_connection = True
return
if not await self.parse_request():
# An error code has been sent, just exit
return
mname = 'do_' + self.command
if not hasattr(self, mname):
self.send_error(HTTPStatus.NOT_IMPLEMENTED,
"Unsupported method (%r)" % self.command)
return
method = getattr(self, mname)
method()
except socket.timeout as e:
#a read or a write timed out. Discard this connection
self.log_error("Request timed out: %r", e)
self.close_connection = True
return
示例2: handle_one_request
# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import REQUEST_URI_TOO_LONG [as 別名]
def handle_one_request(self):
"""Handle a single HTTP request.
You normally don't need to override this method; see the class
__doc__ string for information on how to handle specific HTTP
commands such as GET and POST.
"""
try:
self.raw_requestline = self.rfile.readline(65537)
if len(self.raw_requestline) > 65536:
self.requestline = ''
self.request_version = ''
self.command = ''
self.send_error(HTTPStatus.REQUEST_URI_TOO_LONG)
return
if not self.raw_requestline:
self.close_connection = True
return
if not self.parse_request():
# An error code has been sent, just exit
return
mname = 'do_' + self.command
if not hasattr(self, mname):
self.send_error(
HTTPStatus.NOT_IMPLEMENTED,
"Unsupported method (%r)" % self.command)
return
method = getattr(self, mname)
method()
self.wfile.flush() #actually send the response if not already done.
except socket.timeout as e:
#a read or a write timed out. Discard this connection
self.log_error("Request timed out: %r", e)
self.close_connection = True
return