setAuthorization() public method

Sets the authorization credentials as header.
public setAuthorization ( string $username, string $password )
$username string Username.
$password string Password.
Exemplo n.º 1
0
 /**
  * @param string $request
  * @param string $location
  * @param string $action
  * @param integer $version
  * @param int $one_way
  *
  * @throws \VCR\VCRException It this method is called although VCR is disabled.
  *
  * @return string SOAP response.
  */
 public function doRequest($request, $location, $action, $version, $one_way = 0, $options = array())
 {
     if ($this->status === self::DISABLED) {
         throw new VCRException('Hook must be enabled.', VCRException::LIBRARY_HOOK_DISABLED);
     }
     $vcrRequest = new Request('POST', $location);
     $contentType = $version == SOAP_1_2 ? 'application/soap+xml' : 'text/xml';
     $vcrRequest->setHeader('Content-Type', $contentType . '; charset=utf-8; action="' . $action . '"');
     $vcrRequest->setBody($request);
     if (!empty($options['login'])) {
         $vcrRequest->setAuthorization($options['login'], $options['password']);
     }
     /* @var \VCR\Response $response */
     $requestCallback = self::$requestCallback;
     $response = $requestCallback($vcrRequest);
     return $response->getBody();
 }