[Zope-CVS] CVS: Packages/WebsiteLoadTest/websiteloadtest/common - Request.py:1.7
Andreas Jung
andreas@andreas-jung.com
Wed, 16 Jul 2003 08:40:25 -0400
Update of /cvs-repository/Packages/WebsiteLoadTest/websiteloadtest/common
In directory cvs.zope.org:/tmp/cvs-serv30746/websiteloadtest/common
Modified Files:
Request.py
Log Message:
- some cleanup
=== Packages/WebsiteLoadTest/websiteloadtest/common/Request.py 1.6 => 1.7 ===
--- Packages/WebsiteLoadTest/websiteloadtest/common/Request.py:1.6 Wed Mar 20 08:57:35 2002
+++ Packages/WebsiteLoadTest/websiteloadtest/common/Request.py Wed Jul 16 08:40:20 2003
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.1
+#!/usr/bin/env python2.3
##############################################################################
#
@@ -19,11 +19,10 @@
__version__ = "$Id$"
import sys, time
-from types import DictType,ListType
-import myhttplib
from urllib import getproxies
+from types import DictType,ListType
from urlparse import urlparse
-
+import myhttplib
NS_headers = {
'accept':'text/html, text/plain, image/gif,'
@@ -117,8 +116,7 @@
for k,v in kw.items():
if not k in self.__attrs__:
raise RuntimeError,'Unsupported keyword parameter: %s' % k
-
- setattr(self,k,v)
+ setattr(self, k, v)
# try to determine the host/port either from the URL
# or the HOST header
@@ -132,31 +130,24 @@
else:
self.host,self.port = (fields[1], '80')
- self.path = fields[2]+'?' + fields[4]
+ self.path = fields[2] + '?' + fields[4]
else:
# try to sniff into the HOST header
-
if self.headers.has_key('host'):
v = self.headers['host'].strip()
-
- if v.find(":")>-1:
+ if v.find(":") > -1:
self.host,self.port = v.split(":")
else:
- self.host,self.port = (v,'80')
-
+ self.host,self.port = (v, '80')
else:
raise RuntimeError,'host/port could not be determined'
-
-
def setPostData(self,d):
""" set data for POST request """
-
self.data = d
-
def __str__(self):
""" string representation of request """
@@ -177,21 +168,17 @@
__repr__ = __str__
-
def str_short(self):
""" return a short representation of the request """
-
return '%s http://%s:%s%s' % \
(self.method,self.host,self.port,self.path)
-
def getBody(self,fullurl=0):
body = []
headers = {}
a = body.append
-
if self.useragent:
if self.useragent=='MSIE':
headers = MSIE_headers.copy()
@@ -228,13 +215,4 @@
return '\r\n'.join(body)
-
-if __name__=='__main__':
-
-# r = Request(path='http://www.heise.de/sux?a=b',useragent='NS',throttle=0.0)
-# print r.send(debug_level=0)
-
- r = Request(path='/sux?a=b',useragent='NS',throttle=0.0,headers={'host':'www.heise.de:80'})
- print r.send(debug_level=0)
- print r.getBody()