# -*- coding: iso-8859-1 -*- """ Test container routines. """ import unittest import os import linkcheck.fcgi class TestFcgi (unittest.TestCase): """ Test FastCGI request parsing routines. """ def _test_non_fcgi_env (self): os.environ = {} req = linkcheck.fcgi.FCGI() fs = req.getFieldStorage() doc = ['FCGI TestApp\n' '\n'] doc.append('

FCGI TestApp

') if 'CONTENT_LENGTH' in req.env: cl = int(req.env['CONTENT_LENGTH']) doc.append('
POST data (%s):

' % cl)
            keys = fs.keys()
            keys.sort()
            for k in keys:
                val = fs[k]
                if type(val) == type([]):
                    doc.append('    %-15s :  %s\n' %
                               (k, val))
                else:
                    doc.append('    %-15s :  %s\n' %
                               (k, val.value))
            doc.append('
') doc.append('


')
        keys = req.env.keys()
        keys.sort()
        for k in keys:
            doc.append('%-20s :  %s\n' % (k, req.env[k]))
        doc.append('\n


\n') doc.append('\n') doc = ''.join(doc) req.out.write('Content-length: %s\r\n' 'Content-type: text/html\r\n' 'Cache-Control: no-cache\r\n' '\r\n' % len(doc)) req.out.write(doc) req.finish() def _test_fcgi (self): """ Test FastCGI request parsing routines. """ counter = 0 while linkcheck.fcgi.isFCGI(): req = linkcheck.fcgi.FCGI() counter += 1 fs = req.getFieldStorage() size = int(fs['size'].value) doc = ['*' * size] doc = ''.join(doc) req.out.write('Content-length: %s\r\n' 'Content-type: text/html\r\n' 'Cache-Control: no-cache\r\n' '\r\n' % len(doc)) req.out.write(doc) req.finish()