Forum Discussion

itaykaldi's avatar
itaykaldi
Contributor
11 years ago

Override Content-Length

Is there a way to override Content-Length in rest request?
I need to set 'Length' header to be the same as Content-Length...
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    Unfortunately the only way to do this is using groovy. We do not really support groovy scripting but see if the below helps you.

    Put the below script in a RequestFilter.filterRequest event. It should do what you are asking for:


    def headerValue = context.testCase.getTestStepByName("REST Test Request").httpRequest.messageExchange.getRequestHeaders()["Length"]

    def headers = request.requestHeaders
    headers.put( "Content-Length", headerValue )
    request.requestHeaders = headers