code: protected HttpInvalidMessageException checkResponseValidity() {
          // if this wasn't a HEAD request, then check to make sure we sent the
          // same amount of bytes that were in the content-length header
          if (!MethodValues.HEAD.equals(getRequest().getMethodValue())) {
              long len = getResponse().getContentLength();
              long num = getNumBytesWritten();
              if (HeaderStorage.NOTSET != len && num != len) {
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Response had content-length of " + Long.toString(len) + " but sent " + Long.toString(num));
                  }
                  if (getHttpConfig().getDebugLog().isEnabled(DebugLog.Level.ERROR)) {
                      getHttpConfig().getDebugLog().log(DebugLog.Level.ERROR, HttpMessages.MSG_CONN_INVALID_LENGTHS + Long.toString(len) + " but sent " + Long.toString(num), this);
  
                  }
                  setPersistent(false);
                  return new HttpInvalidMessageException("Response length: " + Long.toString(len) + " " + Long.toString(num));
              }
          }
          return null;
      }
docs: Once the response message has been fully written, perform any last checks
  for correctness. This will return null if the response was valid,
  otherwise it will return the HttpInvalidMessageException that should be
  handed off to the application channel above.
  
  @return HttpInvalidMessageException (null if valid)