コード例 #1
0
ファイル: Client.php プロジェクト: Banjerr/infusionWholesaler
 /**
  * Create new client instance
  *
  * If no specific transport, parser or serializer is passed, default implementations
  * are used.
  *
  * @param string                         $uri
  * @param TransportInterface             $transport
  * @param Parser\ParserInterface         $parser
  * @param Serializer\SerializerInterface $serializer
  */
 public function __construct($uri = null, TransportInterface $transport = null, ParserInterface $parser = null, SerializerInterface $serializer = null)
 {
     $this->uri = $uri;
     $this->transport = $transport ?: new HttpAdapterTransport(HttpAdapterFactory::guess());
     $this->parser = $parser ?: new XmlReaderParser();
     $this->serializer = $serializer ?: new XmlWriterSerializer();
 }
コード例 #2
0
ファイル: Factory.php プロジェクト: fastfeed/fastfeed
 /**
  * @return FastFeed
  */
 public static function create()
 {
     $fastFeed = new FastFeed(HttpAdapterFactory::create('guzzle'), new Logger(false));
     $fastFeed->pushParser(new RSSParser());
     $fastFeed->pushParser(new AtomParser());
     return $fastFeed;
 }
コード例 #3
0
ファイル: Factory.php プロジェクト: nazieb/flashimage
 /**
  * Make a HTTP request to a URL and return its Response
  *
  * @param string $url
  * @return StreamInterface|null
  */
 public function loadUrl($url)
 {
     $http = HttpAdapterFactory::guess();
     $response = $http->get($url);
     if ($response->getStatusCode() >= 300 and $response->getStatusCode() < 400 and $response->hasHeader('Location')) {
         $url = $response->getHeader('Location');
         $response = $http->get($url);
     }
     return $response;
 }
コード例 #4
0
 /**
  * @param string $base_url
  * @param string|null $adaptor_name
  * @throws HttpAdapterException
  */
 public function __construct($base_url, $adaptor_name, HttpClient $httpClient = null)
 {
     if (!is_null($httpClient) && $httpClient instanceof HttpClient) {
         $this->httpClient = $httpClient;
     } else {
         if (is_string($adaptor_name) && HttpAdapterFactory::capable($adaptor_name)) {
             $this->httpClient = HttpAdapterFactory::create($adaptor_name);
         } else {
             $this->httpClient = HttpAdapterFactory::guess();
         }
         $this->httpClient->getConfiguration()->setBaseUri($base_url);
     }
 }
コード例 #5
0
 private function prepareFixtureFile($methodName)
 {
     $tape = $this->createTape($methodName);
     $httpAdapter = HttpAdapterFactory::guess();
     $request = $httpAdapter->getConfiguration()->getMessageFactory()->createRequest('http://httpstat.us/200');
     $response = $httpAdapter->sendRequest($request);
     $exception = new HttpAdapterException();
     $exception->setRequest($httpAdapter->getConfiguration()->getMessageFactory()->createInternalRequest('http://httpstat.us/200'));
     $exception->setResponse($response);
     $track = new Track($request);
     $track->setResponse($response);
     $track->setException($exception);
     $tape->writeTrack($track);
     $tape->store();
 }
コード例 #6
0
 private function getTransport()
 {
     return [new \fXmlRpc\Transport\HttpAdapterTransport(\Ivory\HttpAdapter\HttpAdapterFactory::guess())];
 }
コード例 #7
0
 /**
  * @return PsrHttpAdapterInterface
  */
 protected function getHttpAdapter()
 {
     $preferred_library = HttpAdapterFactory::GUZZLE6;
     return HttpAdapterFactory::guess($preferred_library);
 }
コード例 #8
0
ファイル: FactoryTest.php プロジェクト: jared-fraser/FastFeed
 public function testCreate()
 {
     HttpAdapterFactory::register('mock_adapter', 'Ivory\\HttpAdapter\\MockHttpAdapter');
     $this->assertInstanceOf('FastFeed\\FastFeed', Factory::create('mock_adapter'));
 }
コード例 #9
0
 /**
  * Establish an adapter connection.
  *
  * @param array $config
  *
  * @return \Ivory\HttpAdapter\HttpAdapterInterface
  */
 public function createAdapter(array $config)
 {
     return $this->adapter->create($config['adapter']);
 }