/**
  * @param URL $u
  * @return blaze\lang\String
  */
 public function toExternalForm(URL $u)
 {
     $str = $u->getScheme() . '://';
     if ($u->getUser() != null) {
         $str .= $u->getUser();
         if ($u->getPassword() != null) {
             $str .= ':' . $u->getPassword();
         }
         $str .= '@';
     }
     $str .= $u->getHost();
     if ($u->getPort() != -1) {
         $str .= ':' . $u->getPort();
     }
     if ($u->getPath() != null) {
         $str .= '/' . $u->getPath();
     }
     if ($u->getQuery() != null) {
         $str .= '?' . $u->getQuery();
     }
     if ($u->getFragment() != null) {
         $str .= '#' . $u->getFragment();
     }
     return new \blaze\lang\String($str);
 }
Example #2
0
 /**
  * Constructor
  *
  * @param   util.cmd.ParamString args
  */
 public function __construct(ParamString $args)
 {
     $url = new URL($args->value(0));
     // If protocol string does not contain port number, set default.
     if (self::ESDL_PORT === $url->getPort(self::ESDL_PORT)) {
         $url->setPort(self::ESDL_PORT);
     }
     // Check given URL to inform user if invalid port used.
     if (self::ESDL_PORT !== $url->getPort()) {
         Console::$err->writeLine('Notice: using non-standard port ' . $url->getPort() . ', ESDL services are usually available at port 6449.');
     }
     $this->remote = Remote::forName($url->getURL());
     $this->jndi = $args->value(1);
     $this->processor = new DomXSLProcessor();
     $this->processor->setXSLBuf($this->getClass()->getPackage()->getResource($args->value('lang', 'l', 'xp5') . '.xsl'));
 }
Example #3
0
 /**
  * Setup the class instance. A dsn string must be given with the relevant information
  * about the server and script:
  *
  * Eg: nagios://nagios.xp_framework.net:5667/service_to_monitor
  *
  * @param   string dsn
  */
 public function setup($dsn)
 {
     $url = new URL($dsn);
     $this->server = $url->getHost();
     $this->port = $url->getPort(5667);
     $this->version = $url->getParam('version', NSCA_VERSION_2);
     $this->service = trim($url->getPath(), '/');
     $this->host = $url->getParam('hostname', System::getProperty('host.name'));
     if (FALSE !== $url->getParam('domain', FALSE)) {
         $this->host .= '.' . ltrim($url->getParam('domain'), '.');
     }
 }
 /**
  * Creates a socket
  *
  * @param   peer.URL url
  * @param   string arg
  * @return  peer.Socket
  */
 protected function newSocket(URL $url, $arg)
 {
     return new Socket($url->getHost(), $url->getPort(80));
 }
Example #5
0
 /**
  * @covers \URLParser\URL::__construct
  * @covers \URLParser\URL::getPort
  */
 public function testGetPort()
 {
     $url = new URL($this->testUrl);
     $this->assertEquals($this->port, $url->getPort());
 }
 /**
  * Creates a socket - overridden from parent class
  *
  * @param   peer.URL url
  * @param   string arg
  * @return  peer.Socket
  */
 protected function newSocket(URL $url, $arg)
 {
     sscanf($arg, 'v%d', $version);
     return new SSLSocket($url->getHost(), $url->getPort(443), NULL, $version);
 }
Example #7
0
 public function ipv6AddressAndPort()
 {
     $u = new URL('http://[::1]:8080');
     $this->assertEquals('[::1]', $u->getHost());
     $this->assertEquals(8080, $u->getPort());
 }
 /**
  * Navigate to a given URL
  *
  * @param   string target
  * @param   string params
  * @param   string method
  * @throws  unittest.AssertionFailedError  
  */
 public function navigateTo($target, $params = NULL, $method = HttpConstants::GET)
 {
     if (strstr($target, '://')) {
         $url = new URL($target);
         $this->conn = $this->getConnection(sprintf('%s://%s%s/', $url->getScheme(), $url->getHost(), -1 === $url->getPort(-1) ? '' : ':' . $url->getPort()));
         $params ? $url->setParams($params) : '';
         $this->beginAt($url->getPath(), $url->getParams(), $method);
     } else {
         if ('' !== $target && '/' === $target[0]) {
             $this->beginAt($target, $params, $method);
         } else {
             $base = $this->getBase();
             $this->beginAt(substr($base, 0, strrpos($base, '/')) . '/' . $target, $params, $method);
         }
     }
 }
 /**
  * Parse DSN
  *
  * @param   string dsn
  * @return  bool success
  */
 protected function _parsedsn($dsn)
 {
     if (NULL === $dsn) {
         return TRUE;
     }
     $u = new URL($dsn);
     if (!$u->getHost()) {
         throw new IllegalArgumentException('DSN parsing failed ["' . $dsn . '"]');
     }
     // Scheme
     switch (strtoupper($u->getScheme())) {
         case 'ESMTP':
             $this->ext = TRUE;
             break;
         case 'SMTP':
             $this->ext = FALSE;
             break;
         default:
             throw new IllegalArgumentException('Scheme "' . $u->getScheme() . '" not supported');
     }
     // Copy host and port
     $this->host = $u->getHost();
     $this->port = $u->getPort() ? $u->getPort() : 25;
     // User & password
     if ($u->getUser()) {
         $this->auth = $u->getParam('auth', SMTP_AUTH_PLAIN);
         $this->user = $u->getUser();
         $this->pass = $u->getPassword();
     }
 }