RiteshY
9 years agoOccasional Contributor
Replace request content using RequestFilter.filterRequest does not work
I want to send urlencoded request, to achive that I am using following code in RequestFilter.filterRequest
def requestHeaders = request.getRequestHeaders() def contentType = requestHeaders.get("Content-Type")[0].trim().toLowerCase() def reqContent = context.requestContent if (contentType=="application/x-www-form-urlencoded" && reqContent){ reqContent = java.net.URLEncoder.encode(reqContent.replaceAll('\t', ' ').replaceAll('\r\n|\n', ''), java.nio.charset.StandardCharsets.UTF_8.toString()) context.requestContent = "=$reqContent".toString() }
But It doesn't send URLEncoded request. According to http://blog.smartbear.com/soapui/soapui-pro-holiday-goodies-event-handlers-and-jdbc-connections/ article, it should work. Am I missing something?
I don't want to use SubmitListener.beforeSubmit event with request.setRequestContent as It changes request content in the test and next time it becomes unreadable for anyone.
Any Suggestion folks?
Thanks,
Ritesh