Permalink
Browse files

Set the POSTFIELDS after setting the request method

  • Loading branch information...
1 parent ee9f201 commit 07f4a74b2568b23384ece373f373cb075e6cc3fc @shuber shuber committed Mar 31, 2009
Showing with 27 additions and 24 deletions.
  1. +3 −0 CHANGELOG
  2. +12 −12 curl.php
  3. +12 −12 curl.php4
View
@@ -1,3 +1,6 @@
+2009-03-30 - Sean Huber (shuber@huberry.com)
+ * Set the POSTFIELDS after setting the request method
+
2008-12-19 - Sean Huber (shuber@huberry.com)
* Use dirname(__FILE__) instead of realpath('.')
View
@@ -62,6 +62,18 @@ protected function request($method, $url, $vars = array())
{
$this->handle = curl_init();
+ # Determine the request method and set the correct CURL option
+ switch ($method) {
+ case 'GET':
+ curl_setopt($this->handle, CURLOPT_HTTPGET, true);
+ break;
+ case 'POST':
+ curl_setopt($this->handle, CURLOPT_POST, true);
+ break;
+ default:
+ curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $method);
+ }
+
# Set some default CURL options
curl_setopt($this->handle, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->handle, CURLOPT_COOKIEJAR, $this->cookie_file);
@@ -80,18 +92,6 @@ protected function request($method, $url, $vars = array())
}
curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers);
- # Determine the request method and set the correct CURL option
- switch ($method) {
- case 'GET':
- curl_setopt($this->handle, CURLOPT_HTTPGET, true);
- break;
- case 'POST':
- curl_setopt($this->handle, CURLOPT_POST, true);
- break;
- default:
- curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $method);
- }
-
# Set any custom CURL options
foreach ($this->options as $option => $value) {
curl_setopt($this->handle, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);
View
@@ -69,6 +69,18 @@ class Curl
{
$this->handle = curl_init();
+ # Determine the request method and set the correct CURL option
+ switch ($method) {
+ case 'GET':
+ curl_setopt($this->handle, CURLOPT_HTTPGET, true);
+ break;
+ case 'POST':
+ curl_setopt($this->handle, CURLOPT_POST, true);
+ break;
+ default:
+ curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $method);
+ }
+
# Set some default CURL options
curl_setopt($this->handle, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->handle, CURLOPT_COOKIEJAR, $this->cookie_file);
@@ -87,18 +99,6 @@ class Curl
}
curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers);
- # Determine the request method and set the correct CURL option
- switch ($method) {
- case 'GET':
- curl_setopt($this->handle, CURLOPT_HTTPGET, true);
- break;
- case 'POST':
- curl_setopt($this->handle, CURLOPT_POST, true);
- break;
- default:
- curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $method);
- }
-
# Set any custom CURL options
foreach ($this->options as $option => $value) {
curl_setopt($this->handle, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);

0 comments on commit 07f4a74

Please sign in to comment.