Пример #1
0
    def __init__(self, environ=os.environ, input=sys.stdin, output=sys.stdout):
        Request.__init__(self)
        self.__environ = environ
        self.__input = input
        self.__output = output

        self.method = self.__environ.get('REQUEST_METHOD')
        self.remote_addr = self.__environ.get('REMOTE_ADDR')
        self.remote_user = self.__environ.get('REMOTE_USER')
        self.server_name = self.__environ.get('SERVER_NAME')
        self.server_port = int(self.__environ.get('SERVER_PORT', 0))
        self.scheme = 'http'
        if self.__environ.get('HTTPS') in ('on',
                                           '1') or self.server_port == 443:
            self.scheme = 'https'
        if self.__environ.get('HTTP_COOKIE'):
            self.incookie.load(self.__environ.get('HTTP_COOKIE'))
        self.args = self._getFieldStorage()

        self.cgi_location = self.__environ.get('SCRIPT_NAME')
        self.idx_location = self.cgi_location

        self.path_info = self.__environ.get('PATH_INFO', '')

        if 'TRAC_ENV_PARENT_DIR' in os.environ and self.path_info:
            env_path = '/' + self.path_info.split('/', 2)[1]
            self.path_info = self.path_info[len(env_path):]
            self.cgi_location += env_path
Пример #2
0
    def __init__(self, req, options):
        Request.__init__(self)
        self.req = req

        self.method = self.req.method
        self.server_name = self.req.server.server_hostname
        self.server_port = self.req.connection.local_addr[1]
        self.remote_addr = self.req.connection.remote_ip
        self.remote_user = self.req.user
        self.scheme = 'http'
        if self.req.subprocess_env.get('HTTPS') in ('on', '1') \
                or self.server_port == 443:
            self.scheme = 'https'
        if self.req.headers_in.has_key('Cookie'):
            self.incookie.load(self.req.headers_in['Cookie'])
        self.args = FieldStorageWrapper(self.req)

        # The root uri sometimes has to be explicitly specified because apache
        # sometimes get req.path_info wrong if many <alias> and <location> directives
        # are used.
        if options.has_key('TracUriRoot'):
            root_uri = options['TracUriRoot'].rstrip('/')
            if self.req.uri[:len(root_uri)] != root_uri:
                raise ValueError, \
                     'TracRootUri set to %s but request URL starts with %s' \
                     % (root_uri, self.req.uri[:len(root_uri)])
            self.path_info = self.req.uri[len(root_uri):]
        else:
            self.path_info = self.req.path_info

        if len(self.path_info):
            self.idx_location = self.req.uri[:-len(self.path_info)]
        else:
            self.idx_location = self.req.uri

        if options.has_key('TracEnvParentDir') and self.path_info:
            # We have to remove one path element from path_info when we're
            # using TracEnvParentDir
            self.path_info = re.sub('/[^/]+', '', self.path_info, 1)

        if len(self.path_info):
            self.cgi_location = self.req.uri[:-len(self.path_info)] or '/'
        else:
            self.cgi_location = self.req.uri
Пример #3
0
    def __init__(self, handler, project_name, query_string):
        Request.__init__(self)
        self.__handler = handler

        self.scheme = 'http'
        self.method = self.__handler.command
        self.remote_addr = str(self.__handler.client_address[0])
        self.server_name = self.__handler.server.server_name
        self.server_port = self.__handler.server.server_port
        if self.__handler.headers.has_key('Cookie'):
            self.incookie.load(self.__handler.headers['Cookie'])

        self.cgi_location = '/' + project_name
        self.idx_location = '/'

        environ = {'REQUEST_METHOD': self.method, 'QUERY_STRING': query_string}
        headers = self.__handler.headers
        if self.method in ('GET', 'HEAD'):
            headers = None
        self.args = TracFieldStorage(self.__handler.rfile,
                                     environ=environ,
                                     headers=headers,
                                     keep_blank_values=1)