/**
  * 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();
 }
Exemple #2
0
 /**
  * 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;
 }
 /**
  * @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);
     }
 }
 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();
 }
 private function getTransport()
 {
     return [new \fXmlRpc\Transport\HttpAdapterTransport(\Ivory\HttpAdapter\HttpAdapterFactory::guess())];
 }
 /**
  * @return PsrHttpAdapterInterface
  */
 protected function getHttpAdapter()
 {
     $preferred_library = HttpAdapterFactory::GUZZLE6;
     return HttpAdapterFactory::guess($preferred_library);
 }