예제 #1
0
파일: url.Test.php 프로젝트: poef/ariadne
 function testParseAuthority()
 {
     $starturl = 'http://*****:*****@www.ariadne-cms.org:80/';
     $url = \arc\url::url($starturl);
     $this->assertInstanceOf('\\arc\\url\\Url', $url);
     $this->assertEquals($url . '', $starturl);
 }
예제 #2
0
 /**
  * Send a HTTP request and return the response
  * @param string       $type    The method to use, GET, POST, etc.
  * @param string       $url     The URL to request
  * @param array|string $request The query string
  * @param array        $options Any of the HTTP stream context options, e.g. extra headers.
  * @return string
  */
 public function request($type, $url, $request = null, $options = [])
 {
     $url = \arc\url::url((string) $url);
     if ($type == 'GET' && $request) {
         $url->query->import($request);
         $request = null;
     }
     $options = ['method' => $type, 'content' => $request] + $options;
     $options['headers'] = $this->mergeHeaders(\arc\hash::get('header', $this->options), \arc\hash::get('headers', $this->options), \arc\hash::get('header', $options), \arc\hash::get('headers', $options));
     $options += (array) $this->options;
     $context = stream_context_create(['http' => $options]);
     $result = @file_get_contents((string) $url, false, $context);
     $this->responseHeaders = isset($http_response_header) ? $http_response_header : null;
     //magic php variable set by file_get_contents.
     $this->requestHeaders = isset($options['headers']) ? explode("\r\n", $options['headers']) : [];
     return $result;
 }