Attempts to decrypt the given response.

@param  string|array|null $response

@return string|array|null
501447
public function decryptResponse($response)
    {
        if (!is_string($response)) {
            return $response;
        }

        if ($this->usesEncryption()) {
            return json_decode(
                json_encode(
                    JWT::decode(
                        $response,
                        $this->encryptionKey,
                        array($this->encryptionAlgorithm)
                    )
                ),
                true
            );
        }

        throw EncryptionConfigurationException::undeterminedEncryption();
    }
627113
public static function fromArray(array $response)
    {
        $body = isset($response['body']) ? $response['body'] : null;

        $gzip = isset($response['headers']['Content-Type'])
            && strpos($response['headers']['Content-Type'], 'application/x-gzip') !== false;

        $binary = isset($response['headers']['Content-Transfer-Encoding'])
            && $response['headers']['Content-Transfer-Encoding'] == 'binary';

        // Base64 decode when binary
        if ($gzip || $binary) {
            $body = base64_decode($response['body']);
        }

        return new static(
            isset($response['status']) ? $response['status'] : 200,
            isset($response['headers']) ? $response['headers'] : array(),
            $body
        );
    }
341515
private function unserializeResponse($response)
    {
        $result = unserialize($response);
        if ($response !== 'b:0;' && $result === false) {
            throw new \Exception(substr($response, 0, 5000));
        }

        return $result;
    }
611810
protected function _getHandlerKey(Zend_Http_Response $response = null)
    {
        if ($response) {
            $code = $response->getStatus();
            if ($response->isSuccessful() || $response->isRedirect()) {
                return 'success';
            } elseif ($code < 500 && $code >= 400) {
                return 'client_error';
            } elseif ($code >= 500) {
                return 'server_error';
            }
            // @codeCoverageIgnoreStart
        }
        // @codeCoverageIgnoreEnd
        return 'no_response';
    }
213239
public function decrypt($payload)
    {
        $payload = $this->_getJsonPayload($payload);
        $iv = base64_decode($payload['iv']);
        $decrypted = openssl_decrypt($payload['value'], $this->_cipher, $this->_key, 0, $iv);

        if ($decrypted === false) {
            throw new AnEncrypterException('Could not decrypt the data.');
        }

        return unserialize($decrypted);
    }
1039264
public function parseData(array $response)
    {
        $key = str_replace('.', '_', $this->getMethod()) . '_response';
        return array_key_exists($key, $response) ? $response[$key] : null;
    }
157460
public static function decodeHttpResponse($response) {
    $code = $response->getResponseHttpCode();
    $body = $response->getResponseBody();
    $decoded = null;
    
    if ($code != '200' && $code != '201' && $code != '204') {
      $decoded = json_decode($body, true);
      $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
      if ($decoded != null && isset($decoded['error']['message'])  && isset($decoded['error']['code'])) {
        // if we're getting a json encoded error definition, use that instead of the raw response
        // body for improved readability
        $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
      } else {
        $err .= ": ($code) $body";
      }
      throw new Service\Exception($err, $code);
    }
    
    // Only attempt to decode the response, if the response code wasn't (204) 'no content'
    if ($code != '204') {
      $decoded = json_decode($body, true);
      if ($decoded == null) {
        throw new Service\Exception("Invalid json in service response: $body");
      }
    }
    return $decoded;
  }
236679
public function decrypt($string, $key = null)
    {
        if (null === $key) {
            $key = $this->getEncryptKey();
        }

        $cipherText = base64_decode($string);
        $ivSize     = $this->getMsCryptIvSize();

        $ivDec = substr($cipherText, 0, $ivSize);

        $cipherText = substr($cipherText, $ivSize);

        return mcrypt_decrypt(
            $this->getMcryptCipher(),
            $key,
            $cipherText,
            $this->getMcryptMode(),
            $ivDec
        );
    }
1025907
private function convert_body_string_to_json( $response ) {
		if ( $this instanceof Gitea_API || $this instanceof Bitbucket_API || $this instanceof Bitbucket_Server_API ) {
			$body = wp_remote_retrieve_body( $response );
			if ( null === json_decode( $body ) ) {
				$response['body'] = json_encode( $body );
			}
		}

		return $response;
	}
50690
public function handleResponse($response)
    {
        // recursion for batch
        if (is_array($response)) {
            $response_arr = array();
            foreach ($response as $res) {
                $response_arr[$res->id] = $this->handleResponse($res);
            }
            return $response_arr;
        }

        // return error response
        if (property_exists($response, 'error')) {
            return new Response(null, $response->id, $response->error->code, $response->error->message);
        }

        // return successful response
        return new Response($response->result, $response->id);
    }
478198
protected function respond($response)
    {
        if ($response === null) {
            return $this->mapResponse(true, []);
        }

        if (!empty($response) && !isset($response[0])) {
            $success = null === Arr::get($response, 'error_code');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responseItem) {
            $success = null === Arr::get($responseItem, 'error_code');

            $responses[] = $this->mapResponse($success, $responseItem);
        }

        return $responses;
    }
792638
protected static function handleResponse($response)
    {
        self::resolveContentType($response);

        $body = $response->getBody();
        $response = json_decode($body);

        self::resolveErrorResponse($response);

        return $response;
    }
1187998
protected function decode_response($response) {
        // XMLRPC server in Moodle encodes response using function xmlrpc_encode_request() with method==null
        // see {@link webservice_xmlrpc_server::prepare_response()} . We should use xmlrpc_decode_request() for decoding too.
        $method = null;
        $encoding = null;
        if (preg_match('/^<\?xml version="1.0" encoding="([^"]*)"\?>/', $response, $matches)) {
            // Sometimes xmlrpc_decode_request() fails to recognise encoding, let's help it.
            $encoding = $matches[1];
        }
        $r = xmlrpc_decode_request($response, $method, $encoding);
        return $r;
    }
319060
protected function encrypt(Response $response)
	{
		foreach ($response->headers->getCookies() as $key => $c)
		{
			$encrypted = $this->encrypter->encrypt($c->getValue());

			$response->headers->setCookie($this->duplicate($c, $encrypted));
		}

		return $response;
	}
1248624
private function decodeCookie($cookie)
    {
        if ($this->config->cookieProtectionMethod() == HttpConfig::COOKIE_ENCRYPT) {
            $encrypter = $this->encryption->getEncrypter();
            try {
                if (is_array($cookie)) {
                    return array_map([$this, 'decodeCookie'], $cookie);
                }

                return $encrypter->decrypt($cookie);
            } catch (DecryptException $exception) {
                return null;
            }
        }

        //HMAC
        $hmac = substr($cookie, -1 * HttpConfig::MAC_LENGTH);
        $value = substr($cookie, 0, strlen($cookie) - strlen($hmac));

        if ($this->hmacSign($value) != $hmac) {
            return null;
        }

        return $value;
    }
808354
public function packetResponse(array $response = null)
    {

        // Act as setter
        if (!empty($response)) {
            $this->packets_response = $response;
        }

        return $this->packets_response;
    }
63602
protected function respond($response)
    {
        if (!isset($response[0])) {
            $success = !(array_key_exists('type', $response) && $response['type'] == 'error')
                && !(array_key_exists('status', $response) && $response['status'] == 'error');

            return $this->mapResponse($success, $response);
        }

        $responses = [];

        foreach ($response as $responds) {
            $success = !(array_key_exists('type', $response) && $response['type'] == 'error')
                && !(array_key_exists('status', $response) && $response['status'] == 'error');

            $responses[] = $this->mapResponse($success, $responds);
        }

        return $responses;
    }