- only __CLASS__ is out-dated
- used "new" array style []
Signed-off-by: Roland Häder <roland@mxchange.org>
if (!isset($GLOBALS[__METHOD__])) {
// Determine it
$GLOBALS[__METHOD__] = ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host') != '') && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0));
if (!isset($GLOBALS[__METHOD__])) {
// Determine it
$GLOBALS[__METHOD__] = ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_host') != '') && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0));
// Return cache
return $GLOBALS[__METHOD__];
// Return cache
return $GLOBALS[__METHOD__];
* @param $port Port number to connect to
* @return $response Response array
*/
* @param $port Port number to connect to
* @return $response Response array
*/
- protected function setupProxyTunnel ($host, $port) {
+ protected function setupProxyTunnel (string $host, int $port) {
- $response = array('', '', '');
+ $response = ['', '', ''];
// Do the connect
$respArray = $this->doConnectRequest($host, $port);
// Do the connect
$respArray = $this->doConnectRequest($host, $port);
if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
// Response code is not 200
return $response;
if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
// Response code is not 200
return $response;
// All fine!
return $respArray;
// All fine!
return $respArray;
* @param $port Port number to connect to
* @return $responseArray Array with raw response
*/
* @param $port Port number to connect to
* @return $responseArray Array with raw response
*/
- private function sendRawHttpRequest ($method, $host, $port, array $header = []) {
+ private function sendRawHttpRequest (string $method, string $host, int $port, array $header = []) {
// Minimum raw HTTP/1.1 request
$rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
$rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL;
// Minimum raw HTTP/1.1 request
$rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL;
$rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL;
// Add it as well
$encodedAuth = base64_encode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_password'));
$rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL;
// Add it as well
$encodedAuth = base64_encode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_password'));
$rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL;
// Add last new-line
$rawRequest .= self::HTTP_EOL;
// Add last new-line
$rawRequest .= self::HTTP_EOL;
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HTTP-CLIENT: rawRequest=' . $rawRequest);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HTTP-CLIENT: rawRequest=' . $rawRequest);
// Write request
fwrite($this->getSocketResource(), $rawRequest);
// Write request
fwrite($this->getSocketResource(), $rawRequest);
if (feof($this->getSocketResource())) {
// No response received
return $response;
if (feof($this->getSocketResource())) {
// No response received
return $response;
// Read the first line
$resp = trim(fgets($this->getSocketResource(), 10240));
// Read the first line
$resp = trim(fgets($this->getSocketResource(), 10240));
* @param $port Port number to connect to
* @return $responseArray An array with the read response
*/
* @param $port Port number to connect to
* @return $responseArray An array with the read response
*/
- public function doConnectRequest ($host, $port) {
+ public function doConnectRequest (string $host, int $port) {
// Prepare extra header(s)
// Prepare extra header(s)
'Proxy-Connection' => 'Keep-Alive'
'Proxy-Connection' => 'Keep-Alive'
// Prepare raw request
$responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers);
// Prepare raw request
$responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers);
* @throws UnsupportedOperationException If this method is called
*/
public function seek ($offset, $whence = SEEK_SET) {
* @throws UnsupportedOperationException If this method is called
*/
public function seek ($offset, $whence = SEEK_SET) {
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence);
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('OUTPUT: offset=' . $offset . ',whence=' . $whence);
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
* @throws UnsupportedOperationException If this method is called
*/
public function streamData ($data) {
- self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.');
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-namespace Org\Mxchange\CoreFramework\Task\___;
+namespace Tld\Domain\Project\Task\___;
// Import framework stuff
use Org\Mxchange\CoreFramework\Task\BaseTask;
// Import framework stuff
use Org\Mxchange\CoreFramework\Task\BaseTask;
* @todo 0% done
*/
public function doShutdown () {
* @todo 0% done
*/
public function doShutdown () {
- self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...');