解析响应数据.

@param Response $response

@return DiscussDetail
355625
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if ($jsonData && 0 == $jsonData['retcode']) {
            //成员在线状态
            $statuses = (new Collection($jsonData['result']['mem_status']))->combine('uin', function ($entity) {
                return $entity;
            })->toArray();
            //成员基本信息
            $ruins = (new Collection($jsonData['result']['info']['mem_list']))->combine('mem_uin', 'ruin')
                ->toArray();
            //讨论组基本详情
            $discussData = $jsonData['result']['info'];
            $discussDetailData = [
                'did' => $discussData['did'],
                'name' => $discussData['discu_name'],
            ];
            $members = [];
            foreach ($jsonData['result']['mem_info'] as $memberData) {
                $uin = $memberData['uin'];
                $members[] = EntityFactory::createEntity(DiscussMember::class, [
                   'uin' => $uin,
                   'nick' => $memberData['nick'],
                   'clientType' => isset($statuses[$uin]) ? $statuses[$uin]['client_type'] : null,
                   'status' => isset($statuses[$uin]) ? $statuses[$uin]['status'] : null,
                   'ruin' => isset($ruins[$uin]) ? $ruins[$uin] : null,
                ]);
            }
            $discussDetailData['members'] = new EntityCollection($members);

            return EntityFactory::createEntity(DiscussDetail::class, $discussDetailData);
        }
        throw new ResponseException($jsonData['retcode'], $response);
    }
77991
protected function _setHeaders($response)
    {
        $headers = $this->getConfig('headers');

        if (!is_array($headers)) {
            return $response;
        }

        return $response
            ->withHeader($headers['limit'], (string)$this->getConfig('limit'))
            ->withHeader($headers['remaining'], (string)$this->_getRemainingConnections())
            ->withHeader(
                $headers['reset'],
                (string)Cache::read($this->_getCacheExpirationKey(), static::$cacheConfig)
            );
    }
231674
protected function buildJsonpResponse(Response $response) {
		$content     = (string)$response->getBody();
		$contentType = $response->getHeaderLine('Content-Type');

		if (strpos($contentType, 'application/json') === false) {
			$content = '"' . $content . '"';
		}

		$callback = "{$this->callbackName}({$content});";

		$newResponse = new Response(200);
		$newResponse->getBody()->write($callback);

		return $newResponse->withHeader('Content-Type', 'application/javascript');
	}
1021278
protected function setPsrResponse( \Psr\Http\Message\ResponseInterface $response )
	{
		$this->response->setStatus( $response->getStatusCode() );

		foreach( $response->getHeaders() as $key => $value ) {
			foreach( (array) $value as $val ) {
				$this->response->setHeader( $key, $val );
			}
		}

		return (string) $response->getBody();
	}
1333320
private function _buildResponse($response)
    {
        $sections = explode("\r\n\r\n", $response, 2);
        $body = isset($sections[1]) ? $sections[1] : NULL;
        $headers = array();
        $headerlines = explode("\n", $sections[0]);

        // process status
        list($http, $code, $message) = explode(' ', $headerlines[0], 3);

        // process headers
        foreach (array_slice($headerlines, 1) as $headerline) {
            $headers[] = HeaderField::fromString($headerline);
        }

        $response = new Response($code, $headers, $body);

        return $response;
    }
335999
protected function bbserver_recombine_response( $response ) {
		if ( $this->validate_response( $response ) ) {
			return $response;
		}
		$remote_info_file = '';
		if ( isset( $response->lines ) ) {
			foreach ( (array) $response->lines as $line ) {
				$remote_info_file .= $line->text . "\n";
			}
		}

		return $remote_info_file;
	}
93467
protected function needToUpdateResponse(Response $response)
    {
        $isJsonResponse = $response instanceof JsonResponse || $response->headers->contains('content-type',
                'application/json');

        return $isJsonResponse && !$this->storage->isEmpty();
    }
818500
protected function setResponseHeaders(Response $response)
    {
        $response->headers->set('Access-Control-Allow-Origin', '*');
        $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');

        return $response;
    }
353404
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if ($jsonData && 0 == $jsonData['retcode']) {
            $profileData = $jsonData['result'];
            //注意获取好友详情接口并不返回account和lnick
            return EntityFactory::createEntity(Profile::class, [
                'account' => isset($profileData['account']) ? $profileData['account'] : null,
                'lnick' => isset($profileData['lnick']) ? $profileData['lnick'] : null,
                'face' => $profileData['face'],
                'birthday' => Birthday::createFromArray($profileData['birthday']),
                'occupation' => $profileData['occupation'],
                'phone' => $profileData['phone'],
                'allow' => $profileData['allow'],
                'college' => $profileData['college'],
                'uin' => $profileData['uin'],
                'constel' => $profileData['constel'],
                'blood' => $profileData['blood'],
                'homepage' => $profileData['homepage'],
                'stat' => isset($profileData['stat']) ? $profileData['stat'] : null,
                'vipInfo' => $profileData['vip_info'],
                'country' => $profileData['country'],
                'city' => $profileData['city'],
                'personal' => $profileData['personal'],
                'nick' => $profileData['nick'],
                'shengXiao' => $profileData['shengxiao'],
                'email' => $profileData['email'],
                'province' => $profileData['province'],
                'gender' => $profileData['gender'],
                'mobile' => $profileData['mobile'],
            ]);
        }
        throw new ResponseException($jsonData['retcode'], $response);
    }
958849
public function getResultFromResponse(Response $response)
    {
        $buckets = $response->getData()['aggregations']['variant']['buckets'];

        foreach ($buckets as $bucket) {

            $source = $bucket['value']['hits']['hits'][0]['_source'];

            $data = json_decode($source['scope'], true);
            $element = $data['data'][0];
            $included = $data['included'];

            $included = $this->getIncludedArray($included);
            $mapperClass = $this->getMapperClass($element['type']);

            if (is_null($mapperClass)) {
                throw new EntityNotFoundException("Entity mapper class for {$element['type']} was not found");
            }

            $element['attributes'] = array_merge($element['attributes'], $source);
            $result[] = $this->createObject($mapperClass, $element, $included);
        }

        return $result ?? [];
    }
635892
protected function display($response) {
        // TODO get rid of backwards compat here.
        if($response->alteredSession()) {
            $this->request->setAllSession($response->getAllSession());
        }
        if($response->alteredCookies()) {
            $this->request->setAllCookies($response->getAllCookies());
        }
        $this->request->commitSessionAndCookies();
        if(is_object($response)) {
            $response->compile();
        } else {
            echo $response;
        }
    }
1243104
protected function parseLookupResponse(Response $response)
    {
        $responseData = $response->getBody();
        $responseObject = json_decode($responseData);
        $definitionsData = $responseObject->def;
        $definitions = [];
        foreach ($definitionsData as $definitionData) {
            $definitions[] = new DictionaryDefinition($definitionData);
        }
        return $definitions;
    }
991517
private function processResponse(Response $response)
    {
        $response = $response->getBody()->getContents();
        $response = json_decode($response, true);

        return $response;
    }
570713
protected function _processResponse(Response $response): ResponseSet
    {
        $responseData = $response->getData();

        $actions = $this->getActions();

        $bulkResponses = [];

        if (isset($responseData['items']) && \is_array($responseData['items'])) {
            foreach ($responseData['items'] as $key => $item) {
                if (!isset($actions[$key])) {
                    throw new InvalidException('No response found for action #'.$key);
                }

                $action = $actions[$key];

                $opType = \key($item);
                $bulkResponseData = \reset($item);

                if ($action instanceof AbstractDocumentAction) {
                    $data = $action->getData();
                    if ($data instanceof Document && $data->isAutoPopulate()
                        || $this->_client->getConfigValue(['document', 'autoPopulate'], false)
                    ) {
                        if (!$data->hasId() && isset($bulkResponseData['_id'])) {
                            $data->setId($bulkResponseData['_id']);
                        }
                        if (isset($bulkResponseData['_version'])) {
                            $data->setVersion($bulkResponseData['_version']);
                        }
                    }
                }

                $bulkResponses[] = new BulkResponse($bulkResponseData, $action, $opType);
            }
        }

        $bulkResponseSet = new ResponseSet($response, $bulkResponses);

        if ($bulkResponseSet->hasError()) {
            throw new BulkResponseException($bulkResponseSet);
        }

        return $bulkResponseSet;
    }
781450
public function fromResponse($response)
    {
        $this->page        = $response->list_info->page;
        $this->num_pages   = $response->list_info->num_pages;
        $this->num_results = $response->list_info->num_results;
        $this->page_size   = $response->list_info->page_size;

        property_exists($response, $this->list_type) && $this->setCollection($response->{$this->list_type});

        return $this;
    }
1333726
public static function parseResponse(Response $response)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if ($jsonData && 0 == $jsonData['retcode']) {
            //群成员的vip信息
            $vipInfos = (new Collection($jsonData['result']['vipinfo']))->combine('u', function ($entity) {
                return $entity;
            })->toArray();
            //群成员的名片信息, 如果全部成员都没有设置群名片则会不存在这个字段
            $cards = isset($jsonData['result']['cards']) ? (new Collection($jsonData['result']['cards']))
                ->combine('muin', 'card')
                ->toArray() : [];
            //群成员的简要信息
            $flags = (new Collection($jsonData['result']['ginfo']['members']))->combine('muin', 'mflag')
                ->toArray();
            //群基本详细信息
            $groupData = $jsonData['result']['ginfo'];
            $groupDetailData = [
                'gid' => $groupData['gid'],
                'name' => $groupData['name'],
                'code' => $groupData['code'],
                'owner' => $groupData['owner'],
                'level' => $groupData['level'],
                'createTime' => $groupData['createtime'],
                'flag' => $groupData['flag'],
                'memo' => $groupData['memo'],
                'members' => null,
            ];
            $members = [];
            foreach ($jsonData['result']['minfo'] as $memberData) {
                $uin = $memberData['uin'];
                $member = EntityFactory::createEntity(GroupMember::class, [
                    'flag' => isset($flags[$uin]) ? $flags[$uin] : null,
                    'nick' => $memberData['nick'],
                    'province' => $memberData['province'],
                    'gender' => $memberData['gender'],
                    'uin' => $uin,
                    'country' => $memberData['country'],
                    'city' => $memberData['city'],
                    'card' => isset($cards[$uin]) ? $cards[$uin] : null,
                    'isVip' => isset($vipInfos[$uin]) ? 1 == $vipInfos[$uin]['is_vip'] : false,
                    'vipLevel' => isset($vipInfos[$uin]) ? $vipInfos[$uin]['vip_level'] : 0,
                ]);
                $members[] = $member;
            }
            $groupDetailData['members'] = new EntityCollection($members);

            return EntityFactory::createEntity(GroupDetail::class, $groupDetailData);
        }
        throw new ResponseException($jsonData['retcode'], $response);
    }
764081
private function getResult($response)
    {
        $status = $response->getStatusCode();
        if ($status == 200) {
            return json_decode($response->getBody(), JSON_PRETTY_PRINT);
        } else {
            return [$status => $response->getReasonPhrase()];
        }
    }