當前位置: 首頁>>代碼示例>>Python>>正文


Python HTTPStatus.REQUEST_URI_TOO_LONG屬性代碼示例

本文整理匯總了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 
開發者ID:johnnykv,項目名稱:heralding,代碼行數:29,代碼來源:aioserver.py

示例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 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:38,代碼來源:server.py


注:本文中的http.HTTPStatus.REQUEST_URI_TOO_LONG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。