Update of /cvsroot/pywin32/pywin32/isapi/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1831/test
Modified Files:
extension_simple.py
Log Message:
Handle server variables > 8k in length and also handle IIS6 'UNICODE_'
variables.
Index: extension_simple.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/isapi/test/extension_simple.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** extension_simple.py 6 Oct 2004 05:11:55 -0000 1.1
--- extension_simple.py 14 Dec 2006 08:35:34 -0000 1.2
***************
*** 4,9 ****
# Install this extension, then point your browser to:
# "http://localhost/pyisapi_test/test1"
! # This will execute the method 'test1' below. You can specify any method name
! # at all, but currently there is only 1.
from isapi import isapicon, threaded_extension, ExtensionError
--- 4,9 ----
# Install this extension, then point your browser to:
# "http://localhost/pyisapi_test/test1"
! # This will execute the method 'test1' below. See below for the list of
! # test methods that are acceptable.
from isapi import isapicon, threaded_extension, ExtensionError
***************
*** 34,44 ****
raise AttributeError, "No test named '%s'" % (test_name,)
result = meth(ecb)
ecb.SendResponseHeaders("200 OK", "Content-type: text/html\r\n\r\n",
False)
! print >> ecb, "<HTML><BODY>OK"
! if result:
! print >> ecb, "<pre>"
! print >> ecb, result
! print >> ecb, "</pre>"
print >> ecb, "</BODY></HTML>"
ecb.DoneWithSession()
--- 34,46 ----
raise AttributeError, "No test named '%s'" % (test_name,)
result = meth(ecb)
+ if result is None:
+ # This means the test finalized everything
+ return
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()
***************
*** 51,54 ****
--- 53,91 ----
assert err.errno == winerror.ERROR_INVALID_INDEX, err
return "worked!"
+
+ def test_long_vars(self, ecb):
+ qs = ecb.GetServerVariable("QUERY_STRING")
+ # Our implementation has a default buffer size of 8k - so we test
+ # the code that handles an overflow by ensuring there are more
+ # than 8k worth of chars in the URL.
+ expected_query = ('x' * 8500)
+ if len(qs)==0:
+ # Just the URL with no query part - redirect to myself, but with
+ # a huge query portion.
+ 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),)
+ else:
+ return "Unexpected query portion! Got %d chars, expected %d" % \
+ (len(qs), len(expected_query))
+
+ def test_unicode_vars(self, ecb):
+ # We need to check that we are running IIS6! This seems the only
+ # effective way from an extension.
+ ver = float(ecb.GetServerVariable("SERVER_SOFTWARE").split('/')[1])
+ if ver < 6.0:
+ 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!"
+ if us != unicode(ecb.GetServerVariable("SERVER_NAME")):
+ raise RuntimeError, "Unicode and non-unicode values were not the same"
+ return "worked!"
+
# The entry points for the ISAPI extension.
def __ExtensionFactory__():
|