title: How should I implement a COUNT verb in my RESTful web service?
body: <p>I've written a RESTful web service that supports the standard CRUD operations, and that can return a set of objects matching certain criteria (a SEARCH verb), but I'd like to add a higher-order COUNT verb, so clients can count the resources matching search criteria without having to fetch all of them.</p>
  
  <p>A few options that occur to me:</p>
  
  <ul>
  <li><p>Ignoring the HTTP specification and returning the object count in the response body of a HEAD request.</p></li>
  <li><p>Duplicating the SEARCH verb's logic, but making a HEAD request instead of a GET request. The server then would encode the object count in a response header.</p></li>
  <li><p>Defining a new HTTP method, COUNT, that returns the object count in the response body.</p></li>
  </ul>
  
  <p>I'd prefer the API of the first approach, but I have to strike that option because it's non-compliant. The second approach seems most semantically correct, but the API isn't very convenient: clients will have to deal with response headers, when most of the time they want to be able to do something easy like <code>response.count</code>. So I'm leaning toward the third approach, but I'm concerned about the potential problems involved with defining a new HTTP method.</p>
  
  <p>What would you do?</p>