Navigation Menu

Skip to content

Commit

Permalink
cURL LIB/MDL-17382
Browse files Browse the repository at this point in the history
make send raw post data possible
  • Loading branch information
dongsheng committed Nov 25, 2008
1 parent a054cfa commit 28c5829
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/filelib.php
Expand Up @@ -1889,18 +1889,23 @@ public function head($url, $options = array()){
/**
* HTTP POST method
*/
public function post($url, $params = array(), $options = array()){
public function post($url, $params = '', $options = array()){
$options['CURLOPT_POST'] = 1;
$this->_tmp_file_post_params = array();
foreach ($params as $key => $value) {
if ($value instanceof stored_file) {
$value->add_to_curl_request($this, $key);
} else {
$this->_tmp_file_post_params[$key] = $value;
if (is_array($params)) {
$this->_tmp_file_post_params = array();
foreach ($params as $key => $value) {
if ($value instanceof stored_file) {
$value->add_to_curl_request($this, $key);
} else {
$this->_tmp_file_post_params[$key] = $value;
}
}
$options['CURLOPT_POSTFIELDS'] = $this->_tmp_file_post_params;
unset($this->_tmp_file_post_params);
} else {
// $params is the raw post data
$options['CURLOPT_POSTFIELDS'] = $params;
}
$options['CURLOPT_POSTFIELDS'] = $this->_tmp_file_post_params;
unset($this->_tmp_file_post_params);
return $this->request($url, $options);
}

Expand Down

0 comments on commit 28c5829

Please sign in to comment.