@param string      $url
@param string|null $user
@param string|null $pass

@return HttpTransport
542821
public static function create($url, $user = null, $pass = null)
    {
        $client = new Client([
            'headers' => [
                'User-Agent' => static::getDefaultUserAgent(),
            ],
        ]);

        $conn = new Connection([
            'url' => $url,
            'user' => $user,
            'pass' => $pass,
        ]);

        $transport = new static($conn);
        $transport->setClient($client);

        return $transport;
    }
78598
public function addUserPrefixUrl($url = null) {
		if (empty($url)) {
			return $url;
		}

		$userPrefix = $this->Session->read('Auth.User.prefix');
		if (empty($userPrefix)) {
			return $url;
		}

		if (!is_array($url)) {
			if (($url === '/') || (stripos($url, '/') === false)) {
				return $url;
			}
			$url = Router::parse($url);
		}

		if (isset($url['prefix']) && ($url['prefix'] === false)) {
			$url[$userPrefix] = false;
			if (isset($url['prefix'])) {
				unset($url['prefix']);
			}

			return $url;
		}

		$url[$userPrefix] = true;

		return $url;
	}
139464
public static Connection connect(final Driver driver, final String url,
                                     final String user, final String pass) 
        throws SQLException {
        
        final Properties props = new Properties();

        props.put("user", user);
        props.put("password", pass);

        return driver.connect(url, props);
    }
645168
public function post(string $url, ?array $payload = null): TransportClientResponse {
        return $this->sendRequest($url, array(
            CURLOPT_POST       => 1,
            CURLOPT_POSTFIELDS => $payload
        ));
    }
568656
private function setUserInfo($user, $pass)
    {
        $this->userInfo = $user . (!empty($pass) ? ':' . $pass : '');

        return $this;
    }
766442
public function initialize($url, $user = null, $password = null)
    {
        $count = substr_count($url, '#');
        if ($count === 1) {
            $revision = null;
            list($repoUrl, $module) = explode('#', $url);
        } elseif ($count === 2) {
            list($repoUrl, $module, $revision) = explode('#', $url);
        } else {
            throw new \UnexpectedValueException("No valid VCS url $url");
        }

        $process = new \Arbit\VCSWrapper\CvsCli\Process();
        $process
            ->argument('-d')
            ->argument($repoUrl)
            ->argument('checkout')
            ->argument('-P')
            ->argument('-r')
            ->argument($revision)
            ->argument('-d')
            ->argument($this->root)
            ->argument($module)
            ->execute();
    }
742575
public function connectPersistant( $host, $user, $pass, $database )
	{
		return $this->connectDatabase( "pconnect", $host, $user, $pass, $database );
	}
404377
protected function connect($host, $user, $pass)
    {
        $conn = ftp_connect($host);
        if (($conn === false) || (@ftp_login($conn, $user, $pass) === false)) {
            throw new TransportException(
                is_resource($conn) ? 'Could not login to FTP' : 'Could not make FTP connection'
            );
        }

        return $conn;
    }
227851
public static function getSessionCookieForExportUser($user, $pass) {
        global $wgServerHTTP, $wgScriptPath, $wgODBTechnicalUser;

        $user = urlencode ( $user );
        $pass = urlencode ( $pass );

        // first: request a token
        $apiPath = "/api.php?action=login&format=json&lgname=$user&lgpassword=$pass";
        $response = Http::post ( $wgServerHTTP . $wgScriptPath . $apiPath, array () );
        
        $responseObj = json_decode ( $response );
        if (isset ( $responseObj->login->result ) && $responseObj->login->result == 'NeedToken') {

            // second: re-send token and request the final sessionId
            $cookieprefix = $responseObj->login->cookieprefix;
            $sessionId = $responseObj->login->sessionid;
            $token = urlencode($responseObj->login->token);
            $response = static::post ( $wgServerHTTP . $wgScriptPath . $apiPath . "&lgtoken=$token", array (), array (
                $cookieprefix . '_session' => $sessionId
            ) );
            
            $responseObj = json_decode ( $response );

            // check if login was successful
            if (isset ( $responseObj->login->result ) && $responseObj->login->result != 'Success') {
                throw new Exception ( "Could not login user $wgODBTechnicalUser" );
            }
            $cookieprefix = $responseObj->login->cookieprefix;
            $sessionId = $responseObj->login->sessionid;
            $lguserid = $responseObj->login->lguserid;
            $lgusername = $responseObj->login->lgusername;
            
            return [
                'cookieprefix' => $cookieprefix,
                'sessionId' => $sessionId,
                'lguserid' => $lguserid,
                'lgusername' => $lgusername
            ];
        }
        throw new Exception( "Could not login user '$user'." );
    }
616817
public function updateUser($user,$pass) {
    if($this->userExists($user)) {
      $this->htpwd[$this->getUserIndex($user)] = $user.':'.crypt($pass,substr(str_replace('+','.',base64_encode(pack('N4', mt_rand(),mt_rand(),mt_rand(),mt_rand()))),0,22));
      $this->_save();
      return true;
    } else {
      return false;
    }
  }
1318729
public function get($url, array $data = [], array $headers = [], $cacheMinutes = 0, HttpExceptionHandler $handler = null)
    {
        return $this->send('get', $url, $data, $headers, $cacheMinutes, $handler);
    }
1004112
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {/*{{{*/
    $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https';
    @$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
    @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];

    $request_headers = OAuthRequest::get_headers();

    // let the library user override things however they'd like, if they know
    // which parameters to use then go for it, for example XMLRPC might want to
    // do this
    if ($parameters) {
      $req = new OAuthRequest($http_method, $http_url, $parameters);
    } else {
      // collect request parameters from query string (GET) and post-data (POST) if appropriate (note: POST vars have priority)
      $req_parameters = $_GET;
      if ($http_method == "POST" && @strstr($request_headers["Content-Type"], "application/x-www-form-urlencoded") ) {
        $req_parameters = array_merge($req_parameters, $_POST);
      }

      // next check for the auth header, we need to do some extra stuff
      // if that is the case, namely suck in the parameters from GET or POST
      // so that we can include them in the signature
      if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
        $header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
        $parameters = array_merge($req_parameters, $header_parameters);
        $req = new OAuthRequest($http_method, $http_url, $parameters);
      } else $req = new OAuthRequest($http_method, $http_url, $req_parameters);
    }

    return $req;
  }
574046
public function post($url=NULL, $postdata=NULL) {
		/* Do note that that if you are going to POST JSON you need to set the
		 * content-type of the transfer AFTER you set the postfields, this is done
		 * if you provide the postdata here, if not, take care to do it or the
		 * content-type will be wrong */
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, FALSE);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($curl, CURLOPT_TIMEOUT, 30);
		curl_setopt($curl, CURLOPT_PORT, $this->api_port);

		if($this->api_is_https) {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
			}
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
		} else {
			if(@CURLOPT_PROTOCOLS != 'CURLOPT_PROTOCOLS') {
				curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);
			}
		}
		if(isset($postdata)) {
			curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
		}
		curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
		curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
		curl_setopt($curl, CURLOPT_URL, $url);

		$body = curl_exec($curl);
		if($body === FALSE) {
			$error = curl_error($curl);
			if($error === NULL) {
				$error = 'Failed to connect to the Trusly API';
			}
			throw new Trustly_ConnectionException($error);
		}

		if($this->api_is_https) {
			$ssl_result = curl_getinfo($curl, CURLINFO_SSL_VERIFYRESULT);
			if($ssl_result !== 0) {

				$curl_x509_errors = array(
					'0' => 'X509_V_OK',
					'2' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT',
					'3' => 'X509_V_ERR_UNABLE_TO_GET_CRL',
					'4' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE',
					'5' => 'X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE',
					'6' => 'X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
					'7' => 'X509_V_ERR_CERT_SIGNATURE_FAILURE',
					'8' => 'X509_V_ERR_CRL_SIGNATURE_FAILURE',
					'9' => 'X509_V_ERR_CERT_NOT_YET_VALID',
					'10' => 'X509_V_ERR_CERT_HAS_EXPIRED',
					'11' => 'X509_V_ERR_CRL_NOT_YET_VALID',
					'12' => 'X509_V_ERR_CRL_HAS_EXPIRED',
					'13' => 'X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD',
					'14' => 'X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD',
					'15' => 'X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD',
					'16' => 'X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD',
					'17' => 'X509_V_ERR_OUT_OF_MEM',
					'18' => 'X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT',
					'19' => 'X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN',
					'20' => 'X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
					'21' => 'X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE',
					'22' => 'X509_V_ERR_CERT_CHAIN_TOO_LONG',
					'23' => 'X509_V_ERR_CERT_REVOKED',
					'24' => 'X509_V_ERR_INVALID_CA',
					'25' => 'X509_V_ERR_PATH_LENGTH_EXCEEDED',
					'26' => 'X509_V_ERR_INVALID_PURPOSE',
					'27' => 'X509_V_ERR_CERT_UNTRUSTED',
					'28' => 'X509_V_ERR_CERT_REJECTED',
					'29' => 'X509_V_ERR_SUBJECT_ISSUER_MISMATCH',
					'30' => 'X509_V_ERR_AKID_SKID_MISMATCH',
					'31' => 'X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH',
					'32' => 'X509_V_ERR_KEYUSAGE_NO_CERTSIGN',
					'50' => 'X509_V_ERR_APPLICATION_VERIFICATION'
				);

				$ssl_error_str = null;
				if(isset($curl_x509_errors[$ssl_result])) {
					$ssl_error_str = $curl_x509_errors[$ssl_result];
				}

				$error = 'Failed to connect to the Trusly API. SSL Verification error #' . $ssl_result . ($ssl_error_str?': ' . $ssl_error_str:'');
				throw new Trustly_ConnectionException($error);
			}
		}
		$response_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

		return array($body, $response_code);
	}
1114902
public static function to( $uri = '', $params = array(), $retain = false ) 
	{
		// To avoid // urls we check for a single slash.
		if ( $uri === '/' ) 
		{
			$uri = '';
		}

		// When the uri starts with an @ sign we handle the uri as route alias.
		if ( substr( $uri, 0, 1 ) == '@' ) 
		{
			return static::alias( substr( $uri, 1 ), $params, $retain );
		}

		// Are there already parameters in the uri? Parse them
		// and merge them with current argument parameters
		if ( strpos( $uri, '?' ) !== false )
		{
			$parts = explode( '?', $uri );

			$uri = $parts[0];

			if ( isset( $parts[1] ) )
			{
				parse_str( $parts[1], $old_params );

				$params = array_merge( $old_params, $params );
			}
		}


		// When the uri contains a protocoll or starts with a slash we assume
		// a full url is given and we don't have to add a path offest.
		if ( strpos( $uri, '://' ) === false && substr( $uri, 0, 1 ) !== '/' ) 
		{
			$uri = static::$path_offset.$uri;
		}


		// Try to replace parameters in the uri and remove them from
		// the array so we can append them as get parameters
		foreach( $params as $key => $value )
		{
			// replace the parameter provider
			if ( is_numeric( $key ) && is_string($value) && $value[0] === ':' )
			{
				$param_provider_key = substr( $value, 1 );

				// remove the parameter provider from the parameter list
				unset( $params[$key] );

				if ( array_key_exists( $param_provider_key, static::$parameter_provider ) )
				{
					$params = $params + call_user_func( static::$parameter_provider[$param_provider_key] );
				}
			}

			// replace the parameters
			if ( !is_array($value))
			{
				$uri = str_replace( ':'.$key, $value, $uri, $count );

				if ( $count > 0 )
				{
					unset( $params[$key] );
				}
			}
		}

		// Should we keep the get parameters? If retain is enabled
		// we merge the get parameter array with argument parameters
		if ( $retain )
		{
			$params = array_merge( CCIn::$_instance->GET, $params );
		}

		// When we still got parameters add them to the url
		if ( !empty( $params ) ) 
		{
			$uri .= '?'.http_build_query( $params );
		}

		return $uri;
	}
181567
public function initialize($url, $user = null, $password = null)
    {
        if (!is_file($url) || !is_readable($url)) {
            throw new \RuntimeException("Cannot initialize repository from $url");
        }

        // Try to extract given zip archive
        $archive = new \ZipArchive();
        $return  = $archive->open($url);
        if ($return !== true) {
            throw new \RuntimeException($url, $return);
        }

        // Extract, if archive has been opened successfully
        $archive->extractTo($this->root);

        // Move all files from the repository root to the checkout root.
        $root  = $this->findRepositoryRoot($archive);
        $files = glob($this->root . '/' . $root . '*');
        foreach ($files as $file) {
            rename($file, $this->root . '/' . basename($file));
        }
        rmdir($this->root . '/' . $root);

        // Finished Zip extraction
        $archive->close();
    }
554479
public function get($url, $headers = [], $parameters = null)
    {
        return $this->send(Method::GET, $url, $parameters, $headers);
    }
356880
protected function sendRequest($url)
    {
        $response = null;

        if ($this->curlEnabled) {
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
        } else {
            $response = file_get_contents($url);
        }

        return $response;
    }