Ejemplo n.º 1
0
 /**
  * @param Bringit_Request
  * @return Bringit_Response
  */
 public function dispatch($request)
 {
     $url = $request->url();
     $dnsResolver = new Bringit_DnsResolver();
     $failCount = 0;
     $exceptions = array();
     foreach ($dnsResolver->hostsByName($url->host()) as $ipAddress) {
         try {
             $connector = new Bringit_SocketConnector($ipAddress);
             return $connector->handleRequest($request);
         } catch (Bringit_Exception_ConnectionException $e) {
             $failCount++;
             $exceptions[] = $e;
         }
     }
     // TODO: better failure handling
     throw new Bringit_Exception_ConnectionException(sprintf('%d connection failures: %s', $failCount, implode(', ', $exceptions)));
 }
Ejemplo n.º 2
0
 public function testGetHostsByName()
 {
     $resolver = new Bringit_DnsResolver();
     $this->assertEqual($resolver->hostsByName('localhost'), array('127.0.0.1'));
 }