Пример #1
0
 def _munge_webdav_source_port(self, request, env):
     agent = get_header(USER_AGENT, request.header)
     if self._wdav_client_reg(agent):
         env['WEBDAV_SOURCE_PORT'] = 1
         path_info = env['PATH_INFO']
         path_info = posixpath.join(path_info, 'manage_DAVget')
         path_info = posixpath.normpath(path_info)
         env['PATH_INFO'] = path_info
Пример #2
0
 def _munge_webdav_source_port(self, request, env):
     agent = get_header(USER_AGENT, request.header)
     if self._wdav_client_reg(agent):
         env['WEBDAV_SOURCE_PORT'] = 1
         path_info = env['PATH_INFO']
         path_info = posixpath.join(path_info, 'manage_DAVget')
         path_info = posixpath.normpath(path_info)
         env['PATH_INFO'] = path_info
Пример #3
0
    def handle_request(self, request):
        self.hits.increment()

        DebugLogger.log('B', id(request),
                        '%s %s' % (request.command.upper(), request.uri))

        size = get_header(CONTENT_LENGTH, request.header)
        if size and size != '0':
            size = int(size)
            zhttp_collector(self, request, size)
        else:
            sin = StringIO()
            self.continue_request(sin, request)
Пример #4
0
    def handle_request(self, request):
        self.hits.increment()

        DebugLogger.log('B', id(request),
                        '%s %s' % (request.command.upper(), request.uri))

        size = get_header(CONTENT_LENGTH, request.header)
        if size and size != '0':
            size = int(size)
            zhttp_collector(self, request, size)
        else:
            sin = StringIO()
            self.continue_request(sin, request)
Пример #5
0
    def continue_request(self, sin, request):
        "continue handling request now that we have the stdin"

        s = get_header(CONTENT_LENGTH, request.header)
        if s:
            s = int(s)
        else:
            s = 0
        DebugLogger.log('I', id(request), s)

        env = self.get_environment(request)
        version = request.version
        if version == '1.0' and is_proxying_match(request.request):
            # a request that was made as if this zope was an http 1.0 proxy.
            # that means we have to use some slightly different http
            # headers to manage persistent connections.
            connection_re = proxying_connection_re
        else:
            # a normal http request
            connection_re = CONNECTION

        env['http_connection'] = get_header(connection_re,
                                            request.header).lower()
        env['server_version'] = request.channel.server.SERVER_IDENT

        env['wsgi.output'] = ChannelPipe(request)
        env['wsgi.input'] = sin
        env['wsgi.errors'] = sys.stderr
        env['wsgi.version'] = (1, 0)
        env['wsgi.multithread'] = True
        env['wsgi.multiprocess'] = True
        env['wsgi.run_once'] = True
        env['wsgi.url_scheme'] = env['SERVER_PROTOCOL'].split('/')[0]

        request.channel.current_request = None
        request.channel.queue.append(
            ('Zope2WSGI', env, env['wsgi.output'].start_response))
        request.channel.work()
Пример #6
0
    def continue_request(self, sin, request):
        "continue handling request now that we have the stdin"

        s = get_header(CONTENT_LENGTH, request.header)
        if s:
            s = int(s)
        else:
            s = 0
        DebugLogger.log('I', id(request), s)

        env = self.get_environment(request)
        version = request.version
        if version == '1.0' and is_proxying_match(request.request):
            # a request that was made as if this zope was an http 1.0 proxy.
            # that means we have to use some slightly different http
            # headers to manage persistent connections.
            connection_re = proxying_connection_re
        else:
            # a normal http request
            connection_re = CONNECTION

        env['http_connection'] = get_header(connection_re,
                                            request.header).lower()
        env['server_version'] = request.channel.server.SERVER_IDENT

        env['wsgi.output'] = ChannelPipe(request)
        env['wsgi.input'] = sin
        env['wsgi.errors'] = sys.stderr
        env['wsgi.version'] = (1, 0)
        env['wsgi.multithread'] = True
        env['wsgi.multiprocess'] = True
        env['wsgi.run_once'] = True
        env['wsgi.url_scheme'] = env['SERVER_PROTOCOL'].split('/')[0]

        request.channel.current_request = None
        request.channel.queue.append(('Zope2WSGI', env,
                                      env['wsgi.output'].start_response))
        request.channel.work()
Пример #7
0
    def continue_request(self, sin, request):
        "continue handling request now that we have the stdin"

        s = get_header(CONTENT_LENGTH, request.header)
        if s:
            s = int(s)
        else:
            s = 0
        DebugLogger.log('I', id(request), s)

        env = self.get_environment(request)
        zresponse = make_response(request, env)
        if self._force_connection_close:
            zresponse._http_connection = 'close'
        zrequest = HTTPRequest(sin, env, zresponse)
        request.channel.current_request = None
        request.channel.queue.append((self.module_name, zrequest, zresponse))
        request.channel.work()
Пример #8
0
    def continue_request(self, sin, request):
        "continue handling request now that we have the stdin"

        s = get_header(CONTENT_LENGTH, request.header)
        if s:
            s = int(s)
        else:
            s = 0
        DebugLogger.log('I', id(request), s)

        env = self.get_environment(request)
        zresponse = make_response(request, env)
        if self._force_connection_close:
            zresponse._http_connection = 'close'
        zrequest = HTTPRequest(sin, env, zresponse)
        request.channel.current_request = None
        request.channel.queue.append((self.module_name, zrequest, zresponse))
        request.channel.work()
Пример #9
0
def make_response(request, headers):
    "Simple http response factory"
    # should this be integrated into the HTTPResponse constructor?

    response = ZServerHTTPResponse(stdout=ChannelPipe(request),
                                   stderr=StringIO())
    response._http_version = request.version
    if request.version == '1.0' and is_proxying_match(request.request):
        # a request that was made as if this zope was an http 1.0 proxy.
        # that means we have to use some slightly different http
        # headers to manage persistent connections.
        connection_re = proxying_connection_re
    else:
        # a normal http request
        connection_re = http_server.CONNECTION
    response._http_connection = http_server.get_header(connection_re,
                                                       request.header).lower()
    response._server_version = request.channel.server.SERVER_IDENT
    return response
Пример #10
0
def make_response(request, headers):
    "Simple http response factory"
    # should this be integrated into the HTTPResponse constructor?

    response = ZServerHTTPResponse(stdout=ChannelPipe(request),
                                   stderr=StringIO())
    response._http_version = request.version
    if request.version == '1.0' and is_proxying_match(request.request):
        # a request that was made as if this zope was an http 1.0 proxy.
        # that means we have to use some slightly different http
        # headers to manage persistent connections.
        connection_re = proxying_connection_re
    else:
        # a normal http request
        connection_re = http_server.CONNECTION
    response._http_connection = http_server.get_header(connection_re,
                                                       request.header).lower()
    response._server_version = request.channel.server.SERVER_IDENT
    return response
Пример #11
0
    def continue_request(self, sin, request):
        "continue handling request now that we have the stdin"

        s=get_header(CONTENT_LENGTH, request.header)
        if s:
            s=int(s)
        else:
            s=0
        DebugLogger.log('I', id(request), s)
        env=self.get_environment(request)
        path = request.uri.split('?', 1)[0]
        env['PATH_INFO'] += path
        # why not do the above in self.get_environment(request)?
        env['stdin'] = sin
        env['ZServer.medusa.http_server.http_request'] = request
        try:
            channel_pipe = ChannelPipe(request)
            view = self.get_view(env)
            # mini WSGI server:
            result = view(env, channel_pipe.start_response)
            for part in result:
                # XXX: This needs improvement. Basically, we block ZServer
                # iterating through the answer. If it's long, The ZServer will
                # block while the channel gobbles up all the result in memory.
                # Only after all the result has been absorbed will we return
                # control to the medusa thread to actually serve the view.
                # Instead, we should channel.push() a producer for the answer
                # that iterates the result whenever the medusa thread is ready
                # to push more content.
                #
                # For short content, like debug views, this is ok, but if a
                # view tried, for example, to stream a huge file, this would
                # be bad.
                channel_pipe.write(part)
            channel_pipe.close()
            request.channel.current_request=None
        except:
            log.exception("Failure calling view for %r with env:\n%s\n" %
                          (path, env))
            raise