protected function setRequestMethod($method) {
    switch (strtoupper($method)) {
      case 'HEAD':
        curl_setopt($this->request, CURLOPT_NOBODY, true);
        break;
      case 'GET':
        # Hack to allow a request body to be set via CURLOPT_POSTFIELDS
        # for GET requests.
        curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, 'GET');
        break;
      case 'POST':
        curl_setopt($this->request, CURLOPT_POST, true);
        break;
      default:
        curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, $method);
    }
  }