home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from isapi import isapicon, threaded_extension, ExtensionError
- from isapi.simple import SimpleFilter
- import traceback
- import urllib
- import winerror
- import win32api
-
- try:
- win32api.GetConsoleTitle()
- except win32api.error:
- import win32traceutil
-
-
- class Extension(threaded_extension.ThreadPoolExtension):
-
- def Dispatch(self, ecb):
- print 'Tester dispatching "%s"' % (ecb.GetServerVariable('URL'),)
- url = ecb.GetServerVariable('URL')
- test_name = url.split('/')[-1]
- meth = getattr(self, test_name, None)
- if meth is None:
- raise AttributeError, "No test named '%s'" % (test_name,)
- meth is None
- result = meth(ecb)
- if result is None:
- return None
- ecb.SendResponseHeaders('200 OK', 'Content-type: text/html\r\n\r\n', False)
- print >>ecb, '<HTML><BODY>Finished running test <i>', test_name, '</i>'
- print >>ecb, '<pre>'
- print >>ecb, result
- print >>ecb, '</pre>'
- print >>ecb, '</BODY></HTML>'
- ecb.DoneWithSession()
-
-
- def test1(self, ecb):
-
- try:
- ecb.GetServerVariable('foo bar')
- raise RuntimeError, 'should have failed!'
- except ExtensionError:
- err = None
-
- return 'worked!'
-
-
- def test_long_vars(self, ecb):
- qs = ecb.GetServerVariable('QUERY_STRING')
- expected_query = 'x' * 8500
- if len(qs) == 0:
- me = ecb.GetServerVariable('URL')
- headers = 'Location: ' + me + '?' + expected_query + '\r\n\r\n'
- ecb.SendResponseHeaders('301 Moved', headers)
- ecb.DoneWithSession()
- return None
- if qs == expected_query:
- return 'Total length of variable is %d - test worked!' % (len(qs),)
- return 'Unexpected query portion! Got %d chars, expected %d' % (len(qs), len(expected_query))
-
-
- def test_unicode_vars(self, ecb):
- ver = float(ecb.GetServerVariable('SERVER_SOFTWARE').split('/')[1])
- if ver < 6:
- return 'This is IIS version %g - unicode only works in IIS6 and later' % ver
- us = ecb.GetServerVariable('UNICODE_SERVER_NAME')
- if not isinstance(us, unicode):
- raise RuntimeError, 'unexpected type!'
- isinstance(us, unicode)
- if us != unicode(ecb.GetServerVariable('SERVER_NAME')):
- raise RuntimeError, 'Unicode and non-unicode values were not the same'
- us != unicode(ecb.GetServerVariable('SERVER_NAME'))
- return 'worked!'
-
-
-
- def __ExtensionFactory__():
- return Extension()
-
- if __name__ == '__main__':
- from isapi.install import *
- params = ISAPIParameters()
- sm = [
- ScriptMapParams(Extension = '*', Flags = 0)]
- vd = VirtualDirParameters(Name = 'pyisapi_test', Description = Extension.__doc__, ScriptMaps = sm, ScriptMapUpdate = 'replace')
- params.VirtualDirs = [
- vd]
- HandleCommandLine(params)
-
-