Opens the response envelope

@param array $res
@return string|array|number
764403
static public function openResult($res) {
		if (!is_array($res))
			throw new Exception('Invalid datatype. Array expected!');

		if (isset($res['error']))
			throw new Exception('Server error: '.$res['error']);

		if (!isset($res['result']))
			throw new Exception('Server returned no result.');

		return $res['result'];
	}
433784
protected function parseRPCResult($res)
    {
        $rpcRes = $res['data'];

        if (!empty($rpcRes['output'])) {
            echo $rpcRes['output'];
        }

        if (!empty($rpcRes['exception'])) {
            $exception = new \Exception($rpcRes['exception']['msg'], $rpcRes['exception']['code']);

            $file = new \ReflectionProperty($exception, 'file');
            $file->setAccessible(true);
            $file->setValue($exception, $rpcRes['exception']['file']);

            $line = new \ReflectionProperty($exception, 'line');
            $line->setAccessible(true);
            $line->setValue($exception, $rpcRes['exception']['line']);

            throw $exception;
        }

        if (isset($rpcRes['status']) && $rpcRes['status'] != 200) {
            return false;
        }

        return isset($rpcRes['return']) ? $rpcRes['return'] : null;
    }
274022
public function response(array $errors)
    {
        if (($this->ajax() && ! $this->pjax()) || $this->wantsJson()) {
            return new JsonResponse($errors, ValidationException::VALIDATION_FAILED);
        }

        return $this->redirector->to($this->getRedirectUrl())
            ->withInput($this->except($this->dontFlash))
            // This makes errors display properly (original errors are placed under the key 'errors' instead of 'error')
            ->with('error', $this->getValidatorInstance()->getMessageBag());
    }
936061
private function processData(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseJSON = $result['response'];

        $this->checkJsonError();

        $responseArr = json_decode($responseJSON, true);

        if (!isset($responseArr['token'])) {
            throw new ResponseException('Token key is missing', 404);
        }

        return $responseArr;
    }
94706
protected function output_as_xml($res){
		$result = $this->render_set($res);
		if ($this->simple) return $result;

		$data=$this->xml_start().json_encode($result).$this->xml_end();

		if ($this->as_string) return $data;

		$out = new OutputWriter($data, "");
		$out->set_type("json");
		$this->event->trigger("beforeOutput", $this, $out);
		$out->output("", true, $this->encoding);
	}
898398
private function cleanResponse( $res ) {

		$response_string = $res;
		// this is coming from API
		if( method_exists($res,'getBody') )
			$response_string = (string)$res->getBody();

		$response  = json_decode($response_string);

		return $response;
	}
754374
public static function loadKeyFromX509Resource($res): array
    {
        $key = \openssl_get_publickey($res);

        $details = \openssl_pkey_get_details($key);
        if (isset($details['key'])) {
            $values = self::loadKeyFromPEM($details['key']);
            \openssl_x509_export($res, $out);
            $x5c = \preg_replace('#-.*-#', '', $out);
            $x5c = \preg_replace('~\R~', PHP_EOL, $x5c);
            $x5c = \trim($x5c);
            $values['x5c'] = [$x5c];

            $values['x5t'] = Base64Url::encode(\openssl_x509_fingerprint($res, 'sha1', true));
            $values['x5t#256'] = Base64Url::encode(\openssl_x509_fingerprint($res, 'sha256', true));

            return $values;
        }

        throw new \InvalidArgumentException('Unable to load the certificate');
    }
896618
function open()
    {
        if (!$this->_opened) {
            if (!empty($this->_preamble)) {
                $this->_message = $this->_preamble . "\r\n\r\n";
            }
            $this->_opened = true;
            $_shouldSend = false;
        }

        return $this->_opened;
    }
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;
    }
201015
protected function decodeResponse($resp)
    {
        //Setup a SimpleXML Document
        try {
            $xml = @new \SimpleXMLElement($resp);
        } catch (\Exception $e) {
            throw new MalformedResponseException(sprintf("Could not decode XML Response: %s", $e->getMessage()));
        }

        //If we get back a OAI-PMH error, throw a OaipmhException
        if (isset($xml->error)) {
            $code = (string) $xml->error['code'];
            $msg  = (string) $xml->error;

            throw new OaipmhException($code, $msg);
        }

        return $xml;
    }
811259
public function readLine($res = 'out')
    {
        $str = fgets($this->pipes[$res]);
        if (substr($str, -1) == "\n") {
            $str = substr($str, 0, -1);
        }

        return $str;
    }
1270652
public static function open(array $options = [])
    {
        // get the method passed in $options else use port
        $method = array_get($options, 'method', 'post');
        $attributes['method'] = self::getMethod($method);

        $attributes['action'] = self::getAction($options);
        $attributes['accept-charset'] = array_get($options, 'charset', 'UTF-8');
        //
        //PUT and PATCH and DELETE
        //
        //if form use files
        if (isset($options['files']) || in_array('files', $options)) {
            $options['enctype'] = 'multipart/form-data';
        }

        $attributes = array_merge(
            $attributes, array_except($options, self::$reserved)
        );

        $attributes = Html::attributes($attributes);

        $token = self::token();

        return '<form'.$attributes.'>'.$token;
    }
976074
public function getCoverUrlAttribute($res = 1280)
    {
        return str_replace('-', '/', Options::replace(Endpoints::ART_URL, [
            'key' => $this->album->cover,
            'res' => $res,
        ]));
    }
1124080
public static function arrayKeyUpper($arr)
    {
        return array_map(function($item){
            if(is_array($item)) {
                $item = self::arrayKeyUpper($item);
            }
            return $item;
        },array_change_key_case($arr,CASE_UPPER));
    }
149325
protected function getHttpResponse($status, array $headers = [])
    {
        if (array_key_exists($status, self::HTTP_RESPONSES)) {
            $response = self::HTTP_RESPONSES[$status];
        } else {
            $response = self::HTTP_RESPONSES[self::HTTP_NOT_IMPLEMENTED];
        }

        $handshake = [
            sprintf(self::RESPONSE_LINE_FORMAT, $status, $response),
        ];

        foreach ($headers as $name => $value) {
            $handshake[] = sprintf(self::HEADER_LINE_FORMAT, $name, $value);
        }

        return implode($handshake, "\r\n") . "\r\n\r\n";
    }
130804
public function response($rst)
    {
        $result = [];
        if ($rst->isCompleted) {
            $result['url'] = $this->formatUrl($rst->key);
            $result['title'] = $rst->name;
            $result['original'] = $rst->originName;
            $result['type'] = '.' . $rst->extension;
            $result['size'] = $rst->size;
        }
        if ($rst->isOk) {
            $result['state'] = 'SUCCESS';
        } else {
            $result['state'] = $rst['error'];
        }

        return json_encode($result);
    }
239722
public function open($options = [])
    {
        $options['method'] = self::getMethod($options);

        $options['action'] = self::getAction($options);

        $options['accept-charset'] = 'UTF-8';

        if (isset($options['files']) && $options['files']) {
            $options['enctype'] = 'multipart/form-data';
        }

        $options = $this->attributes($options);

        return '<form'.$options.'>';
    }