smallfreak
10 months agoNew Contributor
Content-Length calculation wrong when posting UTF-8 content
The current project is driving me crazy ... I carefully followed the "Unicode Best-Practice" guide (https://support.smartbear.com/readyapi/docs/testing/best-practices/unicode-support.html) which c...
- 10 months ago
As it turned out, SOAPUI DID calculate the Content-Length correct. However the back end service did not.
The confusion was about the line endings. The header lines generated by SOAPUI were CRLF, the body however was LF only. Both the server and notepad++ did expand them to CRLF and obviously the server did count the expanded content, missing a byte for every line in the body.
I did a replacement on the body content before I sent the request://replace all wrong line-endings: \n --> \r\n body = body.replace("\r\n","\n").replace("\n","\r\n") def request = testRunner.testCase.getTestStepByName("UpdateVariables") as RestTestRequestStep //set body request.testRequest.setRequestContent(body)
Afterwards the content was a few bytes larger and the server was happy.
Maybe there is a more simple solution to have all line endings the same - and in a defined manner.