MCPcopy Index your code
hub / github.com/RustPython/RustPython / is_cgi

Method is_cgi

Lib/http/server.py:1087–1110  ·  view source on GitHub ↗

Test whether self.path corresponds to a CGI script. Returns True and updates the cgi_info attribute to the tuple (dir, rest) if self.path requires running a CGI script. Returns False otherwise. If any exception is raised, the caller should assume that self.p

(self)

Source from the content-addressed store, hash-verified

1085 return SimpleHTTPRequestHandler.send_head(self)
1086
1087 def is_cgi(self):
1088 """Test whether self.path corresponds to a CGI script.
1089
1090 Returns True and updates the cgi_info attribute to the tuple
1091 (dir, rest) if self.path requires running a CGI script.
1092 Returns False otherwise.
1093
1094 If any exception is raised, the caller should assume that
1095 self.path was rejected as invalid and act accordingly.
1096
1097 The default implementation tests whether the normalized url
1098 path begins with one of the strings in self.cgi_directories
1099 (and the next character is a '/' or the end of the string).
1100
1101 """
1102 collapsed_path = _url_collapse_path(self.path)
1103 dir_sep = collapsed_path.find('/', 1)
1104 while dir_sep > 0 and not collapsed_path[:dir_sep] in self.cgi_directories:
1105 dir_sep = collapsed_path.find('/', dir_sep+1)
1106 if dir_sep > 0:
1107 head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
1108 self.cgi_info = head, tail
1109 return True
1110 return False
1111
1112
1113 cgi_directories = ['/cgi-bin', '/htbin']

Callers 2

do_POSTMethod · 0.95
send_headMethod · 0.95

Calls 2

_url_collapse_pathFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected