Changeset 8089


Ignore:
Timestamp:
Dec 12, 2010, 11:14:16 AM (10 years ago)
Author:
patdenice
Message:

feature 2057: use http_build_query instead of add_url_params for GET data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/admin/include/functions.php

    r8086 r8089  
    17081708  $method  = empty($post_data) ? 'GET' : 'POST';
    17091709  $request = empty($post_data) ? '' : http_build_query($post_data, '', '&');
    1710   $src     = add_url_params($src, $get_data, '&');
     1710  if (!empty($get_data))
     1711  {
     1712    $src .= strpos($src, '?') === false ? '?' : '&';
     1713    $src .= http_build_query($get_data, '', '&');
     1714  }
    17111715
    17121716  // Initialize $dest
     
    17241728    {
    17251729      @curl_setopt($ch, CURLOPT_POST, 1);
    1726       @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
     1730      @curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
    17271731    }
    17281732    $content = @curl_exec($ch);
     
    17481752      'http' => array(
    17491753        'method' => $method,
    1750         'content' => $request,
    17511754        'user_agent' => $user_agent,
    17521755      )
    17531756    );
     1757    if ($method == 'POST')
     1758    {
     1759      $opts['http']['content'] = $request;
     1760    }
    17541761    $context = @stream_context_create($opts);
    17551762    $content = @file_get_contents($src, false, $context);
     
    17741781  $http_request  = $method." ".$path." HTTP/1.0\r\n";
    17751782  $http_request .= "Host: ".$host."\r\n";
    1776   $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
    1777   $http_request .= "Content-Length: ".strlen($request)."\r\n";
     1783  if ($method == 'POST')
     1784  {
     1785    $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
     1786    $http_request .= "Content-Length: ".strlen($request)."\r\n";
     1787  }
    17781788  $http_request .= "User-Agent: ".$user_agent."\r\n";
    17791789  $http_request .= "Accept: */*\r\n";
Note: See TracChangeset for help on using the changeset viewer.