Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#487·autocannon

Feature: adding the whole response to verifyBody callback

Author: moty66Created Apr 24, 2023Updated Aug 12, 2025

For many reasons, it will be useful to access the original request and the whole response when verifying the body

javascript
const isFn = typeof this.opts.verifyBody === 'function'
if (isFn && !this.opts.verifyBody(resp.body)) {
  return this.emit('mismatch', resp.body)
} else if (!isFn && this.opts.expectBody && this.opts.expectBody !== resp.body) {
  return this.emit('mismatch', resp.body)
}

I think adding a second parameter to the callback verifyBody(resp.body, resp) will not break anything and will be useful for advanced body verifications

Can I make a pull request for this feature

Source: mcollina/autocannon

View original on GitHubView discussion on GitHub