Beispiel #1
0
    def render_GET(self, request):
        if 'service' not in request.args:
            # dumb client
            for key, val in dont_cache():
                request.setHeader(key, val)

            log.msg('Dumb client, sending %s' %
                    os.path.join(self.gitpath, 'info', 'refs'))
            return File(os.path.join(self.gitpath, 'info', 'refs'),
                        'text/plain; charset=utf-8').render_GET(request)

        else:
            # smart client
            if request.args['service'][0] not in [
                    'git-upload-pack', 'git-receive-pack'
            ]:
                return "Invalid RPC: " + request.args['service'][0]

            rpc = request.args['service'][0][4:]
            request.write(git_packet('# service=git-' + rpc) + git_packet())
            cmd = self.gitcommand
            args = [
                os.path.basename(cmd), rpc, '--stateless-rpc',
                '--advertise-refs', self.gitpath
            ]

            return GitCommand(cmd, args).render(request)
Beispiel #2
0
    def sendErrorAndDisconnect(self, msg):
        self.transport.write(git_packet(msg))
        self.transport.loseConnection()

        # return None so it can be used
        # in a return statement in dataReceived for simplicity
        return None
Beispiel #3
0
    def render_GET(self, request):
        if 'service' not in request.args:
            # dumb client
            for key, val in dont_cache():
                request.setHeader(key, val)

            log.msg('Dumb client, sending %s' % os.path.join(
                                                self.gitpath, 'info', 'refs'))
            return File(os.path.join(self.gitpath, 'info', 'refs'),
                        'text/plain; charset=utf-8').render_GET(request)

        else:
            # smart client
            if request.args['service'][0] not in ['git-upload-pack',
                                                  'git-receive-pack']:
                return "Invalid RPC: " + request.args['service'][0]

            rpc = request.args['service'][0][4:]
            request.write(git_packet('# service=git-' + rpc) + git_packet())
            cmd = self.gitcommand
            args = [os.path.basename(cmd), rpc, '--stateless-rpc',
                    '--advertise-refs', self.gitpath]

            return GitCommand(cmd, args).render(request)