コード例 #1
0
ファイル: CURL.php プロジェクト: hutchike/YAWF
 /**
  * Perform an HTTP method at a URL with optional headers and data to send
  *
  * @param String $method the The HTTP method to use for the request
  * @param String $url the The URL to request
  * @param Array $headers optional headers to send
  * @param String $data optional data to put or post (may also be an Array)
  * @return String the web server response content
  */
 public static function method($method, $url, $headers = array(), $data = NULL)
 {
     // Parse a "user:password@" URL prefix for basic auth by
     // removing it, like taking the meat out of the sandwich
     // and being sure to remember the protocol we're using.
     $protocol = '';
     $auth = '';
     if (preg_match('/^(https?:\\/\\/)?([^:]+:[^@]+)@(.+)$/', $url, $matches)) {
         list($all, $protocol, $auth, $url) = $matches;
     }
     $url = $protocol . $url;
     // Set the static properties to return test data to the mock client
     self::$method = $method;
     self::$url = $url;
     self::$headers = $headers;
     self::$data = $data;
     self::$auth = $auth;
     // Return data that has been set by "CURL::set_returned_content()"
     return self::$returned_content;
 }