/** * Method to test get(). * * @return void * * @covers Windwalker\Http\HttpClient::get */ public function testGet() { $url = new Uri('http://example.com/?foo=bar'); $this->instance->get($url, array('flower' => 'sakura'), array('X-Foo' => 'Bar')); $this->assertEquals('GET', $this->transport->request->getMethod()); $this->assertEquals('http://example.com/?foo=bar&flower=sakura', $this->transport->request->getRequestTarget()); $this->assertEquals('', $this->transport->request->getBody()->__toString()); $this->assertEquals(array('X-Foo' => array('Bar')), $this->transport->request->getHeaders()); }
/** * getList * * @return array */ public static function getList() { if (!static::$images) { $http = new HttpClient(); $response = $http->get('https://unsplash.it/list'); $images = json_decode($response->getBody()->__toString()); foreach ($images as $image) { static::$images[$image->id] = $image; } } return static::$images; }
/** * prepareAssetData * * @param string $url * * @return string */ public function prepareAssetData($url) { // Convert url to relative path $file = $this->regularizeUrl($url); // Init Http if (PlatformHelper::isWindows()) { // $file = str_replace('localhost', '127.0.0.1', $file); } $http = new HttpClient(); $content = $http->get($file)->getBody()->getContents(); // Using handle method to prepare file $content = $this->handleFile($content, $file); return "\n\n/* File: {$url} */\n\n" . $content; }