Esempio n. 1
0
 function testParseCommonURLS()
 {
     $commonUrls = ['ftp://ftp.is.co.za/rfc/rfc1808.txt', 'http://www.ietf.org/rfc/rfc2396.txt', 'ldap://[2001:db8::7]/c=GB?objectClass?one', 'mailto:John.Doe@example.com', 'news:comp.infosystems.www.servers.unix', 'tel:+1-816-555-1212', 'telnet://192.0.2.16:80/', 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2', '//google.com', '../../relative/', 'file:///C:/'];
     foreach ($commonUrls as $sourceUrl) {
         $url = \arc\url::safeUrl($sourceUrl);
         $this->assertEquals('' . $url, $sourceUrl);
     }
 }
Esempio n. 2
0
 function testparseSafeUrl()
 {
     $starturl = 'http://www.ariadne-cms.org/?frop=1;frml=2&frup=3';
     $url = \arc\url::safeUrl($starturl);
     $query = $url->query;
     $this->assertTrue(isset($query['frop']));
     $this->assertTrue(isset($query['frml']));
     $this->assertTrue(isset($query['frup']));
     $this->assertTrue($query['frop'] == '1');
     $this->assertTrue($query['frml'] == '2');
     $this->assertTrue($query['frup'] == '3');
     $this->assertFalse($query['frop'] == '1;frml=2');
     $this->assertFalse($query['frml'] == '2;frup=3');
 }
Esempio n. 3
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;
 }