Replace request content using RequestFilter.filterRequest does not work
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'context.requestContent = reqContent'
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I try to get request content in SubmitListener.beforeSubmit using context.requestContent. It returns blank.
I tried setting context.requestContent in SubmitListener.beforeSubmit but it does't work either.
context.requestContent = reqContent also doesn't work in RequestFilter.filterRequest
-Ritesh
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
log.info reqContent prints encoded request.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
context.requestContent = reqContent
You need to check the raw request, not in the request editor if the change has happened or not, just in case it was not check in this way earlier.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am checking RAW request not the request section. Please see following screencast
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I could not see the suggested statement in the script.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's a GIF file. You should be able to see raw request in the animation. (May be download the file and see it. Somehow, It's super slow in forum window)
Also, I am using following line to set the content which is not very different that you are suggesting.
context.requestContent = "=$reqContent".toString()
I tried with what you are suggesting and result is same.
-Ritesh
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ritesh,
Did you ever resolve this? No matter what I set context.requestContent to inside the RequestFilter.filterRequest event, it always sends the original value.
Jahmai
