Skip to content

Commit

Permalink
Use existing curl_opt equest methods instead of custom request
Browse files Browse the repository at this point in the history
For POST and PUT, use the existing curlopt options instead of
custom_request.

Fixes #4515
  • Loading branch information
Ikke committed Aug 5, 2012
1 parent c8fa0a9 commit 707bd27
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion classes/kohana/request/client/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public function _send_message(Request $request)
// Response headers
$response_headers = array();

$options = array();

// Set the request method
$options[CURLOPT_CUSTOMREQUEST] = $request->method();
$options = $this->_set_curl_request_method($request, $options);

// Set the request body. This is perfectly legal in CURL even
// if using a request other than POST. PUT does support this method
Expand Down Expand Up @@ -107,4 +109,27 @@ public function _send_message(Request $request)
return $response;
}

/**
* Sets the appropriate curl request options. Uses the responding options
* for POST and PUT, uses CURLOPT_CUSTOMREQUEST otherwise
* @param Request $request
* @param array $options
* @return array
*/
public function _set_curl_request_method(Request $request, array $options)
{
switch ($request->method()) {
case Request::POST:
$options[CURLOPT_POST] = TRUE;
break;
case Request::PUT:
$options[CURLOPT_PUT] = TRUE;
break;
default:
$options[CURLOPT_CUSTOMREQUEST] = $request->method();
break;
}
return $options;
}

} // End Kohana_Request_Client_Curl

0 comments on commit 707bd27

Please sign in to comment.