Browse files

Use existing curl_opt equest methods instead of custom request

For POST and PUT, use the existing curlopt options instead of
custom_request.

Fixes #4515
  • Loading branch information...
1 parent c8fa0a9 commit 707bd2745149c3d34b34c5f5ea06a857cb8fd34f @Ikke Ikke committed Aug 5, 2012
Showing with 26 additions and 1 deletion.
  1. +26 −1 classes/kohana/request/client/curl.php
View
27 classes/kohana/request/client/curl.php
@@ -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
@@ -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.