Python http.HTTPStatus.NOT_IMPLEMENTED Examples
The following are 30
code examples of http.HTTPStatus.NOT_IMPLEMENTED().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
http.HTTPStatus
, or try the search function
.
Example #1
Source File: edapi_plug.py From Trade-Dangerous with Mozilla Public License 2.0 | 6 votes |
def do_GET(self): split_url = urlsplit(self.path) if split_url.path == "/callback": parsed_url = parse_qs(split_url.query) self.server.callback_code = parsed_url.get("code", [None])[0] self.server.callback_state = parsed_url.get("state", [None])[0] self.send_response(HTTPStatus.OK) body_text = b"<p>You can close me now.</p>" else: self.send_response(HTTPStatus.NOT_IMPLEMENTED) body_text = b"<p>Something went wrong.</p>" self.end_headers() self.wfile.write(b"<html><head><title>EDAPI Frontier Login</title></head>") self.wfile.write(b"<body><h1>AUTHENTICATION</h1>") self.wfile.write(body_text) self.wfile.write(b"</body></html>")
Example #2
Source File: routes.py From dffml with MIT License | 6 votes |
def service_files(self, request): if self.upload_dir is None: return web.json_response( {"error": "File listing not allowed"}, status=HTTPStatus.NOT_IMPLEMENTED, headers={"Cache-Control": "no-cache"}, ) files: List[Dict[str, Any]] = [] for filepath in pathlib.Path(self.upload_dir).rglob("**/*.*"): filename = str(filepath).replace(self.upload_dir + "/", "") files.append( {"filename": filename, "size": filepath.stat().st_size} ) return web.json_response(files)
Example #3
Source File: server.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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
Example #4
Source File: test_httpservers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #5
Source File: test_httpservers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #6
Source File: test_httpservers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' self.con.putrequest('GET', '/') self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #7
Source File: test_httpservers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_invalid_requests(self): response = self.request('/', method='FOO') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED) # requests must be case sensitive,so this should fail too response = self.request('/', method='custom') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED) response = self.request('/', method='GETs') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED)
Example #8
Source File: server.py From Imogen with MIT License | 5 votes |
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
Example #9
Source File: server.py From Imogen with MIT License | 5 votes |
def do_POST(self): """Serve a POST request. This is only implemented for CGI scripts. """ if self.is_cgi(): self.run_cgi() else: self.send_error( HTTPStatus.NOT_IMPLEMENTED, "Can only POST to CGI scripts")
Example #10
Source File: routes.py From dffml with MIT License | 5 votes |
def service_upload(self, request): if self.upload_dir is None: return web.json_response( {"error": "Uploads not allowed"}, status=HTTPStatus.NOT_IMPLEMENTED, headers={"Cache-Control": "no-cache"}, ) filepath = os.path.abspath( os.path.join(self.upload_dir, request.match_info["filepath"]) ) if not filepath.startswith(os.path.abspath(self.upload_dir)): return web.json_response( {"error": "Attempted path traversal"}, status=HTTPStatus.BAD_REQUEST, ) reader = await request.multipart() field = await reader.next() if field.name != "file": return web.json_response( {"error": "Missing 'file' field"}, status=HTTPStatus.BAD_REQUEST, ) # Can't rely on Content-Length if transfer is chunked. size = 0 with open(filepath, "wb") as f: while True: chunk = await field.read_chunk() # 8192 bytes by default. if not chunk: break size += len(chunk) f.write(chunk) return web.json_response(OK)
Example #11
Source File: test_utils.py From opentelemetry-python with Apache License 2.0 | 5 votes |
def test_http_status_to_canonical_code(self): for status_code, expected in ( (HTTPStatus.OK, StatusCanonicalCode.OK), (HTTPStatus.ACCEPTED, StatusCanonicalCode.OK), (HTTPStatus.IM_USED, StatusCanonicalCode.OK), (HTTPStatus.MULTIPLE_CHOICES, StatusCanonicalCode.OK), (HTTPStatus.BAD_REQUEST, StatusCanonicalCode.INVALID_ARGUMENT), (HTTPStatus.UNAUTHORIZED, StatusCanonicalCode.UNAUTHENTICATED), (HTTPStatus.FORBIDDEN, StatusCanonicalCode.PERMISSION_DENIED), (HTTPStatus.NOT_FOUND, StatusCanonicalCode.NOT_FOUND), ( HTTPStatus.UNPROCESSABLE_ENTITY, StatusCanonicalCode.INVALID_ARGUMENT, ), ( HTTPStatus.TOO_MANY_REQUESTS, StatusCanonicalCode.RESOURCE_EXHAUSTED, ), (HTTPStatus.NOT_IMPLEMENTED, StatusCanonicalCode.UNIMPLEMENTED), (HTTPStatus.SERVICE_UNAVAILABLE, StatusCanonicalCode.UNAVAILABLE), ( HTTPStatus.GATEWAY_TIMEOUT, StatusCanonicalCode.DEADLINE_EXCEEDED, ), ( HTTPStatus.HTTP_VERSION_NOT_SUPPORTED, StatusCanonicalCode.INTERNAL, ), (600, StatusCanonicalCode.UNKNOWN), (99, StatusCanonicalCode.UNKNOWN), ): with self.subTest(status_code=status_code): actual = http_status_to_canonical_code(int(status_code)) self.assertEqual(actual, expected, status_code)
Example #12
Source File: test_httpservers.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #13
Source File: server.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def do_POST(self): """Serve a POST request. This is only implemented for CGI scripts. """ if self.is_cgi(): self.run_cgi() else: self.send_error( HTTPStatus.NOT_IMPLEMENTED, "Can only POST to CGI scripts")
Example #14
Source File: test_httpservers.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_command(self): self.con.request('GET', '/') res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #15
Source File: test_httpservers.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #16
Source File: test_httpservers.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_version_none_get(self): self.con._http_vsn_str = '' self.con.putrequest('GET', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #17
Source File: test_httpservers.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_head_keep_alive(self): self.con._http_vsn_str = 'HTTP/1.1' self.con.putrequest('GET', '/') self.con.putheader('Connection', 'keep-alive') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, HTTPStatus.NOT_IMPLEMENTED)
Example #18
Source File: test_httpservers.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_invalid_requests(self): response = self.request('/', method='FOO') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED) # requests must be case sensitive,so this should fail too response = self.request('/', method='custom') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED) response = self.request('/', method='GETs') self.check_status_and_reason(response, HTTPStatus.NOT_IMPLEMENTED)
Example #19
Source File: httpserver.py From febrev-venom with GNU General Public License v3.0 | 5 votes |
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
Example #20
Source File: httpserver.py From febrev-venom with GNU General Public License v3.0 | 5 votes |
def do_POST(self): """Serve a POST request. This is only implemented for CGI scripts. """ if self.is_cgi(): self.run_cgi() else: self.send_error( HTTPStatus.NOT_IMPLEMENTED, "Can only POST to CGI scripts")
Example #21
Source File: server.py From android_universal with MIT License | 5 votes |
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
Example #22
Source File: server.py From android_universal with MIT License | 5 votes |
def do_POST(self): """Serve a POST request. This is only implemented for CGI scripts. """ if self.is_cgi(): self.run_cgi() else: self.send_error( HTTPStatus.NOT_IMPLEMENTED, "Can only POST to CGI scripts")
Example #23
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_messaging_extension_configuration_query_settings_url( # pylint: disable=unused-argument self, turn_context: TurnContext, query: MessagingExtensionQuery ) -> MessagingExtensionResponse: raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #24
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_signin_verify_state(self, turn_context: TurnContext): raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #25
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_signin_token_exchange(self, turn_context: TurnContext): raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #26
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_file_consent_accept( # pylint: disable=unused-argument self, turn_context: TurnContext, file_consent_card_response: FileConsentCardResponse, ): raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #27
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_file_consent_decline( # pylint: disable=unused-argument self, turn_context: TurnContext, file_consent_card_response: FileConsentCardResponse, ): raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #28
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_app_based_link_query( # pylint: disable=unused-argument self, turn_context: TurnContext, query: AppBasedLinkQuery ) -> MessagingExtensionResponse: raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #29
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_messaging_extension_query( # pylint: disable=unused-argument self, turn_context: TurnContext, query: MessagingExtensionQuery ) -> MessagingExtensionResponse: raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)
Example #30
Source File: teams_activity_handler.py From botbuilder-python with MIT License | 5 votes |
def on_teams_messaging_extension_select_item( # pylint: disable=unused-argument self, turn_context: TurnContext, query ) -> MessagingExtensionResponse: raise _InvokeResponseException(status_code=HTTPStatus.NOT_IMPLEMENTED)