Lines Matching full:path
159 1. One line identifying the request type and path
167 <command> <path> <version>
170 <path> is a string containing path information for the request,
172 <path> is encoded using the URL encoding scheme (using %xx to signify
186 <command> <path>
225 - command, path and version are the broken-down request line;
271 are in self.command, self.path, self.request_version and
327 command, path = words[:2]
335 self.command, self.path = command, path
338 # against open redirect attacks possibly triggered if the path starts
339 # with '//' because http clients treat //path as an absolute URI
340 # without scheme (similar to http://path) rather than a path.
341 if self.path.startswith('//'):
342 self.path = '/' + self.path.lstrip('/') # Reduce to a single /
699 path = self.translate_path(self.path)
701 if os.path.isdir(path):
702 parts = urllib.parse.urlsplit(self.path)
703 if not parts.path.endswith('/'):
714 index = os.path.join(path, index)
715 if os.path.isfile(index):
716 path = index
719 return self.list_directory(path)
720 ctype = self.guess_type(path)
726 if path.endswith("/"):
730 f = open(path, 'rb')
776 def list_directory(self, path):
785 list = os.listdir(path)
794 displaypath = urllib.parse.unquote(self.path,
797 displaypath = urllib.parse.unquote(self.path)
809 fullname = os.path.join(path, name)
812 if os.path.isdir(fullname):
815 if os.path.islink(fullname):
833 def translate_path(self, path):
834 """Translate a /-separated PATH to the local filename syntax.
842 path = path.split('?',1)[0]
843 path = path.split('#',1)[0]
845 trailing_slash = path.rstrip().endswith('/')
847 path = urllib.parse.unquote(path, errors='surrogatepass')
849 path = urllib.parse.unquote(path)
850 path = posixpath.normpath(path)
851 words = path.split('/')
853 path = self.directory
855 if os.path.dirname(word) or word in (os.curdir, os.pardir):
858 path = os.path.join(path, word)
860 path += '/'
861 return path
879 def guess_type(self, path):
882 Argument is a PATH (a filename).
893 base, ext = posixpath.splitext(path)
899 guess, _ = mimetypes.guess_type(path)
907 def _url_collapse_path(path):
909 Given a URL path, remove extra '/'s and '.' path elements and collapse
910 any '..' references and returns a collapsed path.
918 Raises: IndexError if too many '..' occur within the path.
922 path, _, query = path.partition('?')
923 path = urllib.parse.unquote(path)
925 # Similar to os.path.split(os.path.normpath(path)) but specific to URL
926 # path semantics rather than local operating system semantics.
927 path_parts = path.split('/')
973 def executable(path):
975 return os.access(path, os.X_OK)
1017 """Test whether self.path corresponds to a CGI script.
1020 (dir, rest) if self.path requires running a CGI script.
1024 self.path was rejected as invalid and act accordingly.
1027 path begins with one of the strings in self.cgi_directories
1031 collapsed_path = _url_collapse_path(self.path)
1044 def is_executable(self, path):
1045 """Test whether argument path is an executable file."""
1046 return executable(path)
1048 def is_python(self, path):
1049 """Test whether argument path is a Python script."""
1050 head, tail = os.path.splitext(path)
1056 path = dir + '/' + rest
1057 i = path.find('/', len(dir)+1)
1059 nextdir = path[:i]
1060 nextrest = path[i+1:]
1063 if os.path.isdir(scriptdir):
1065 i = path.find('/', len(dir)+1)
1073 # a possible additional path, to be stored in PATH_INFO.
1082 if not os.path.exists(scriptfile):
1087 if not os.path.isfile(scriptfile):