Forum Discussion

detvetdu's avatar
detvetdu
Occasional Contributor
8 years ago

Assertion fail for valid HTTP code 204

In earlier versions than 1.9 of ReadyApi the assertion for HTTP 204 worked fine. 

In this version I get failed assertion for HTTP code 204 when i response header returns "Content-Length: 0"

with error message:

"Wrong server response: responses with the 204 status code must not contain the "Content-Length" header."

 

I can't find anything on https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html that supports that Content-lenghth header is not allowed.

 

Is there any reason why this assertions behavior have changed?

I tested in version 1.8.5 and there it works fine

  • AV's avatar
    AV
    SmartBear Alumni (Retired)

    Hello, detvetdu,

    thanks for reaching out us, this assertion behaviour was changed basing on customer's request. Here is some additional information about that:

     

    According to section 3.3.2 of RFC 7230 (Proposed Standard, RFC 7230):

     

    A server MUST NOT send a Content-Length header field in any response
    with a status code of 1xx (Informational) or 204 (No Content). A
    server MUST NOT send a Content-Length header field in any 2xx
    (Successful) response to a CONNECT request (Section 4.3.6 of
    [RFC7231]).

    • detvetdu's avatar
      detvetdu
      Occasional Contributor

      If you add extra check in the assertion for http codes you add assertions for standard as well.

      Shouldn't that be an assertion for the header is following the http standard?

       

      I agree that http 204 should not contain content length header. But the assertions for valid http codes do to much check with this new feature.

       

       

    • performerj's avatar
      performerj
      Occasional Contributor

      Ok, just tried the maintenance build and that fixed the problem.  Thanks!

  • vervuwi's avatar
    vervuwi
    New Contributor

    At least it would be nice if the end-user would have control over this behaviour. Can this option be turned of somewhere so that not all our tests that assert on a 204 fail due to this? In the mean time the dev team can start implementing the fix for no longer sending the 'content-length' header ...

     

    I could be mistaken, but it seems that this change is also not included in the release notes for version 1.9 ...

      • performerj's avatar
        performerj
        Occasional Contributor

        We recently installed Ready! API 1.9.0 and I am finding this behavior of HTTP 204 asserts failing due to a Content Length being specified in the response header.

         

        I was looking for a workaround that could be applied at the virt level (e.g. in a response script) that would suppress the sending of the content length.  Does anyone else have a workaround for this, either at the virt level or at the assert level?