mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-02 20:04:43 +00:00
updated
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2589 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
d821abce85
commit
9413039083
1 changed files with 53 additions and 49 deletions
|
|
@ -5,66 +5,70 @@ Test container routines.
|
|||
|
||||
import unittest
|
||||
import os
|
||||
import sys
|
||||
|
||||
import linkcheck.fcgi
|
||||
|
||||
class TestFcgi (unittest.TestCase):
|
||||
"""
|
||||
Test FastCGI request parsing routines.
|
||||
"""
|
||||
|
||||
def _test_non_fcgi_env (self):
|
||||
os.environ = {}
|
||||
req = linkcheck.fcgi.FCGI()
|
||||
doc = ['<HTML><HEAD><TITLE>FCGI TestApp</TITLE></HEAD>\n'
|
||||
'<BODY>\n']
|
||||
doc.append('<H2>FCGI TestApp</H2><P>')
|
||||
if req.env.has_key('CONTENT_LENGTH'):
|
||||
cl = int(req.env['CONTENT_LENGTH'])
|
||||
doc.append('<br><b>POST data (%s):</b><br><pre>' % cl)
|
||||
keys = fs.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
val = fs[k]
|
||||
if type(val) == type([]):
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val))
|
||||
else:
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val.value))
|
||||
doc.append('</pre>')
|
||||
doc.append('<P><HR><P><pre>')
|
||||
keys = req.env.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
doc.append('<b>%-20s :</b> %s\n' % (k, req.env[k]))
|
||||
doc.append('\n</pre><P><HR>\n')
|
||||
doc.append('</BODY></HTML>\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.
|
||||
"""
|
||||
# XXX inactive
|
||||
counter = 0
|
||||
try:
|
||||
while isFCGI():
|
||||
req = FCGI()
|
||||
counter += 1
|
||||
try:
|
||||
fs = req.getFieldStorage()
|
||||
size = int(fs['size'].value)
|
||||
doc = ['*' * size]
|
||||
except:
|
||||
doc = ['<HTML><HEAD><TITLE>FCGI TestApp</TITLE></HEAD>\n'
|
||||
'<BODY>\n']
|
||||
doc.append('<H2>FCGI TestApp</H2><P>')
|
||||
doc.append('<b>request count</b> = %d<br>' % counter)
|
||||
doc.append('<b>pid</b> = %s<br>' % os.getpid())
|
||||
if req.env.has_key('CONTENT_LENGTH'):
|
||||
cl = int(req.env['CONTENT_LENGTH'])
|
||||
doc.append('<br><b>POST data (%s):</b><br><pre>' % cl)
|
||||
keys = fs.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
val = fs[k]
|
||||
if type(val) == type([]):
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val))
|
||||
else:
|
||||
doc.append(' <b>%-15s :</b> %s\n' %
|
||||
(k, val.value))
|
||||
doc.append('</pre>')
|
||||
doc.append('<P><HR><P><pre>')
|
||||
keys = req.env.keys()
|
||||
keys.sort()
|
||||
for k in keys:
|
||||
doc.append('<b>%-20s :</b> %s\n' % (k, req.env[k]))
|
||||
doc.append('\n</pre><P><HR>\n')
|
||||
doc.append('</BODY></HTML>\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()
|
||||
except:
|
||||
import traceback
|
||||
f = file('traceback', 'w')
|
||||
traceback.print_exc(file = f)
|
||||
#f.write('%s' % doc)
|
||||
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()
|
||||
|
||||
|
||||
def test_suite ():
|
||||
|
|
|
|||
Loading…
Reference in a new issue