New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use existing curl_opt equest methods instead of custom request #283
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -24,8 +24,10 @@ public function _send_message(Request $request) | ||
// Response headers | // Response headers | ||
$response_headers = array(); | $response_headers = array(); | ||
|
|
||
$options = array(); | |||
|
|||
// Set the request method | // Set the request method | ||
$options[CURLOPT_CUSTOMREQUEST] = $request->method(); | $options = $this->_set_curl_request_method($request, $options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you read the issue linked to this pull request, you'll see that it actually gave a problem to someone. |
|||
|
|
||
// Set the request body. This is perfectly legal in CURL even | // Set the request body. This is perfectly legal in CURL even | ||
// if using a request other than POST. PUT does support this method | // if using a request other than POST. PUT does support this method | ||
|
@@ -107,4 +109,27 @@ public function _send_message(Request $request) | ||
return $response; | 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) | |||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's public, shouldn't start with _ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just following the style of this file. Most methods that start with a _ are public. |
|||
{ | |||
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 | } // End Kohana_Request_Client_Curl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two lines is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although they aren't necessary, I do always add them for clarity. It tells someone reading the code there's going to be an array.