Пример #1
0
def capture_main(conf):
    print 'creating capture server on port %d' % (conf.capture_port,)

    def capture_handler(x):
        up = {'inp': '', 'final': {}}

        @on(x, 'request_start')
        def go(*args):
            print 'capture: start %s' % (str(args[1]),)

        @on(x, 'request_body')
        def body(chunk):
            up['inp'] += chunk

        @on(x, 'request_done')
        def done(trailers):
            with open(os.path.join(conf.outdir, conf.outfile), 'a') as f:
                f.write(up['inp'])
                f.write('\n')
                f.close()
            print 'finished capture'
            x.response_start(200, 'OK', [])
            x.response_done([])

    capture_serve = HttpServer(host='', port=conf.capture_port)
    capture_serve.on('exchange', capture_handler)
Пример #2
0
def capture_main(conf):
    print 'creating capture server on port %d' % (conf.capture_port, )

    def capture_handler(x):
        up = {'inp': '', 'final': {}}

        @on(x, 'request_start')
        def go(*args):
            print 'capture: start %s' % (str(args[1]), )

        @on(x, 'request_body')
        def body(chunk):
            up['inp'] += chunk

        @on(x, 'request_done')
        def done(trailers):
            with open(os.path.join(conf.outdir, conf.outfile), 'a') as f:
                f.write(up['inp'])
                f.write('\n')
                f.close()
            print 'finished capture'
            x.response_start(200, 'OK', [])
            x.response_done([])

    capture_serve = HttpServer(host='', port=conf.capture_port)
    capture_serve.on('exchange', capture_handler)
Пример #3
0
def http_main(conf):
    print 'Loading configuration into http base server!'
    base = BaseServer(conf)
    print 'creating HTTP server on port %d' % (conf.http_port,)

    def http_handler(x):
        @on(x, 'request_start')
        def go(*args):
            print 'HTTP: start %s' % (str(args[1]),)
            base.paths.get(util.make_ident(x.method, x.uri), base.fourohfour)(x)

        @on(x, 'request_body')
        def body(chunk):
            #print 'body: %s' % chunk
            pass

        @on(x, 'request_done')
        def done(trailers):
            #print 'done: %s' % str(trailers)
            pass

    http_serve = HttpServer(host='', port=conf.http_port)
    http_serve.on('exchange', http_handler)
Пример #4
0
def http_main(conf):
    print 'Loading configuration into http base server!'
    base = BaseServer(conf)
    print 'creating HTTP server on port %d' % (conf.http_port, )

    def http_handler(x):
        @on(x, 'request_start')
        def go(*args):
            print 'HTTP: start %s' % (str(args[1]), )
            base.paths.get(util.make_ident(x.method, x.uri),
                           base.fourohfour)(x)

        @on(x, 'request_body')
        def body(chunk):
            #print 'body: %s' % chunk
            pass

        @on(x, 'request_done')
        def done(trailers):
            #print 'done: %s' % str(trailers)
            pass

    http_serve = HttpServer(host='', port=conf.http_port)
    http_serve.on('exchange', http_handler)