SOAP refactoring

This commit is contained in:
Miroslav Stampar 2011-04-17 21:39:00 +00:00
parent c7ff5dcbeb
commit a7366bf710
6 changed files with 19 additions and 11 deletions

View File

@ -98,7 +98,7 @@ class Agent:
newValue = self.cleanupPayload(newValue, origValue)
if "POSTxml" in conf.paramDict and place == PLACE.POST:
if place == PLACE.SOAP:
root = ET.XML(paramString)
iterator = root.getiterator(parameter)

View File

@ -441,7 +441,7 @@ def paramToDict(place, parameters=None):
if conf.parameters.has_key(place) and not parameters:
parameters = conf.parameters[place]
if place != "POSTxml":
if place != PLACE.SOAP:
parameters = parameters.replace(", ", ",")
if place == PLACE.COOKIE:

View File

@ -25,6 +25,7 @@ from extra.safe2bin.safe2bin import safecharencode
from extra.safe2bin.safe2bin import safechardecode
from lib.core.data import conf
from lib.core.data import logger
from lib.core.enums import PLACE
from lib.core.settings import UNICODE_ENCODING
from lib.core.settings import URLENCODE_CHAR_LIMIT
from lib.core.settings import URLENCODE_FAILSAFE_CHARS
@ -89,7 +90,7 @@ def urldecode(value, encoding=None):
return result
def urlencode(value, safe="%&=", convall=False, limit=False):
if conf.direct or "POSTxml" in conf.paramDict:
if conf.direct or PLACE.SOAP in conf.paramDict:
return value
count = 0

View File

@ -38,6 +38,7 @@ class DBMS:
class PLACE:
GET = "GET"
POST = "POST"
SOAP = "SOAP"
URI = "URI"
COOKIE = "Cookie"
UA = "User-Agent"

View File

@ -68,17 +68,18 @@ def __setRequestParams():
if conf.data:
conf.data = conf.data.replace("\n", " ")
conf.parameters[PLACE.POST] = conf.data
# Check if POST data is in xml syntax
if re.match("[\n]*<(\?xml |soap\:|ns).*>", conf.data):
conf.paramDict["POSTxml"] = True
__paramDict = paramToDict("POSTxml", conf.data)
place = PLACE.SOAP
else:
__paramDict = paramToDict(PLACE.POST, conf.data)
place = PLACE.POST
conf.parameters[place] = conf.data
__paramDict = paramToDict(place, conf.data)
if __paramDict:
conf.paramDict[PLACE.POST] = __paramDict
conf.paramDict[place] = __paramDict
__testableParameters = True
conf.method = HTTPMETHOD.POST

View File

@ -149,9 +149,11 @@ class Connect:
url = "%s?%s" % (url, get)
requestMsg += "?%s" % get
if conf.method == HTTPMETHOD.POST:
if conf.parameters.has_key(PLACE.POST) and not post:
post = conf.parameters[PLACE.POST]
if conf.method == HTTPMETHOD.POST and not post:
for place in (PLACE.POST, PLACE.SOAP):
if conf.parameters.has_key(place):
post = conf.parameters[place]
break
requestMsg += " %s" % httplib.HTTPConnection._http_vsn_str
@ -466,6 +468,9 @@ class Connect:
if PLACE.POST in conf.parameters:
post = urlencode(conf.parameters[PLACE.POST] if place != PLACE.POST or not value else value)
if PLACE.SOAP in conf.parameters:
post = conf.parameters[PLACE.SOAP] if place != PLACE.SOAP or not value else value
if PLACE.COOKIE in conf.parameters:
cookie = conf.parameters[PLACE.COOKIE] if place != PLACE.COOKIE or not value else value