📣 An issue occured with the embedded container registry on October 25 2021, between 10:30 and 12:10 (UTC+2). Any persisting issues should be reported to CC-IN2P3 Support. 🐛

Commit 8d2422b6 authored by Thibaut Salanon's avatar Thibaut Salanon
Browse files

add port with hostname

parent 7b2efebb
/vendor/
/composer.lock
/.idea/
......@@ -42,8 +42,18 @@ class Query
public function __construct($hostname, $view = '', $operation = 'lavoisier', $accept='xml')
{
$this->setSecureMode(false);
$this->hostname = $hostname;
if(parse_url($hostname,PHP_URL_HOST) != null){
$this->hostname = parse_url($hostname,PHP_URL_HOST);
}else{
$this->hostname = parse_url($hostname,PHP_URL_PATH);
}
if(parse_url($hostname,PHP_URL_PORT) != null){
$this->port = strval(parse_url($hostname,PHP_URL_PORT));
}else{
$this->port = '8080';
}
$this->operation = $operation;
$this->view = $view;
$this->path = '';
......@@ -83,6 +93,21 @@ class Query
$this->port = $port;
}
public function getPort()
{
return $this->port;
}
public function getHostname()
{
return $this->hostname;
}
public function setHostname($hostname)
{
$this->hostname = $hostname;
}
public function setOperation($operation)
{
$this->operation = $operation;
......
......@@ -90,4 +90,17 @@ class QueryTest extends \PHPUnit_Framework_TestCase
}
public function testParsedUrl(){
$q = new Query('cclavoisierfr.in2p3.fr:8080', 'OPSCORE_SITE', 'lavoisier');
$this->assertEquals('cclavoisierfr.in2p3.fr', $q->getHostname());
$this->assertEquals('8080', $q->getPort());
$q = new Query('cclavoisierfr.in2p3.fr', 'OPSCORE_SITE', 'lavoisier');
$this->assertEquals('cclavoisierfr.in2p3.fr', $q->getHostname());
$this->assertEquals('8080', $q->getPort());
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment