解析响应数据.

@param Response $response
@param Friend   $friend

@return int
491861
public static function parseResponse(Response $response, Friend $friend)
    {
        $jsonData = \GuzzleHttp\json_decode($response->getBody(), true);
        if ($jsonData && 0 == $jsonData['retcode']) {
            $info = (new Collection($jsonData['result']))->filter(function ($info) use ($friend) {
                return $info['uin'] == $friend->getUin();
            })->first();

            return $info ? $info['lnick'] : null;
        }
        throw new ResponseException($jsonData['retcode'], $response);
    }
157779
public boolean contains(Friend friend) {
		for (final Friend f : getFriends()) {
			if (StringUtils.parseName(f.getUserId()).equals(
					StringUtils.parseName(friend.getUserId()))) {
				return true;
			}
		}
		return false;
	}
1045635
public function onSwooleRequest($request, $response)
    {
        if (Start::$testUnity) {
            $server_port = $request->server_port;
        } else {
            $server_port = $this->getServerPort($request->fd);
        }

        $middleware_names = $this->portManager->getMiddlewares($server_port);
        $context = [];
        $path = $request->server['path_info'];
        $middlewares = $this->middlewareManager->create($middleware_names, $context, [$request, $response], true);
        //before
        try {
            $this->middlewareManager->before($middlewares);
            //client_data进行处理
            $route = $this->portManager->getRoute($server_port);
            try {
                $route->handleClientRequest($request);
                $controller_name = $route->getControllerName();
                $method_name = $this->portManager->getMethodPrefix($server_port) . $route->getMethodName();
                $path = $route->getPath();
                if ($route->getMethodName() == ConsulHelp::HEALTH) {//健康检查
                    $response->end('ok');
                } else {
                    $controller_instance = ControllerFactory::getInstance()->getController($controller_name);
                    if ($controller_instance != null) {
                        $controller_instance->setContext($context);
                        $controller_instance->setRequestResponse($request, $response, $controller_name, $method_name, $route->getParams());
                    } else {
                        throw new \Exception('no controller');
                    }
                }
            } catch (\Throwable $e) {
                $route->errorHttpHandle($e, $request, $response);
            }
        } catch (\Exception $e) {
            //被中断
        }
        //after
        try {
            $this->middlewareManager->after($middlewares, $path);
        } catch (\Exception $e) {
            //被中断
        }
        $this->middlewareManager->destory($middlewares);
        if (Start::getDebug()) {
            secho("DEBUG", $context);
        }
        unset($context);
    }
1250760
private void recordSerializeResponse(RpcResponseCommand responseCommand) {
        if (!RpcInternalContext.isAttachmentEnable()) {
            return;
        }
        RpcInternalContext context = RpcInternalContext.getContext();
        int cost = context.getStopWatch().tick().read();
        int respSize = RpcProtocol.getResponseHeaderLength()
            + responseCommand.getClazzLength()
            + responseCommand.getContentLength()
            + responseCommand.getHeaderLength();
        // 记录响应序列化大小和请求序列化耗时
        context.setAttachment(RpcConstants.INTERNAL_KEY_RESP_SIZE, respSize);
        context.setAttachment(RpcConstants.INTERNAL_KEY_RESP_SERIALIZE_TIME, cost);
    }
146853
public function deny($friendId)
    {

        $uri = $this->buildUserResourceUri('deny', $friendId);
        $response = $this->makeAuthenticatedApiRequest($uri);

        return $response->user;

    }
243517
protected function response($request, ResponseInterface $response)
    {
        $header = Response::getHeaderOutput($response);
        $headerLength = $length = strlen($header);
        $body = $response->getBody();
        if ($bodySize = $body->getSize() !== null) {
            $length += $bodySize;
        }

        $chunksize = 65520;
        do {
            for ($p = 0; $p + $chunksize < $headerLength; $p += $chunksize) {
                if ($this->sendChunk($request, substr($header, $p, $chunksize)) === false) {
                    $this->log('warning', "send response failed.");
                    break 2;
                }
            }
            $remainder = substr($header, $p);
            try {
                $body->rewind();
                $this->sendChunk($request, $remainder . $body->read($chunksize - strlen($remainder)));
                while (!$body->eof()) {
                    $this->sendChunk($request, $body->read($chunksize));
                }

            } catch (\RuntimeException $e) {
                $this->log('error', $e->getTraceAsString());
                break;
            }

        } while (false);

        $this->endRequest($request, 0, 0);

        return true;
    }
1089584
private function isSuccessful(Response $response): bool
    {
        if ($response->statusCode()->value() !== 200) {
            return false;
        }

        $json = Json::decode((string) $response->body());

        return count($json['errors']) === 0;
    }
18986
def _get_friends_count(session, user_id):
        
        response = session.fetch('friends.get', user_id=user_id, count=1)
        return response["count"]
1003753
private function parseCet(ResponseInterface $response, $photoSavePath = '', $saveName = '')
    {
        $body = $this->checkAndThrow($response);

        $crawler = new Crawler($body);
        // 教务信息
        $ret['info'] = [
            'year'   => $crawler->filter('#Label1')->text(),
            'term'   => $crawler->filter('#Label2')->text(),
            'remark' => $crawler->filter('#Label3')->text(),
        ];
        // 可报名列表
        $ret['list'] = Parser::table($crawler, '#DBGrid', [
            ['chk', function (Crawler $crawler, $getValueMethod) {
                return $crawler->filter('input')->attr('name');
            }],
            'name', 'type', '', 'can_apply', 'require', 'fit', 'limit', 'remark', 'markup',
        ], 0, 1);
        // 已报名列表
        $ret['applied'] = Parser::table($crawler, '#DBGridInfo', [
            'no', 'name', '', '', 'id_card', 'is_pay', 'original_no', 'reserve_type', 'reserve_grade', ['delete_id', function (Crawler $crawler, $getValueMethod) {
                if (preg_match('/\'(.*?)\'/', $crawler->filter('a')->attr('href'), $matches)) {
                    return str_replace('$', ":", $matches[1]);
                }

                return '';
            }],
        ], 8);
        // 学生信息
        $ret['student'] = [
            'photo'   => $crawler->filter('#xszp')->attr('src'),
            'id_card' => $crawler->filter('#Labsfzh')->text(),
        ];
        // 是否下载学生照片
        if ($photoSavePath) {
            if (!$saveName) {
                $saveName = 'student-photo-' . $this->getUsername() . '.png';
            }
            // 头像下载地址
            $downloadUrl = Config::get('url.student_photo');
            // 下载文件
            $response = $this->request('get', [$downloadUrl, [], [
                'sink' => $photoSavePath . $saveName,
            ]]);

            $ret['student']['photo_save'] = $saveName;
        }

        return $ret;
    }
618026
public static function getTransferredSize(ServerRequestInterface $request, ResponseInterface $response): string
    {
        return (string) (self::getMessageSize($request, 0) + self::getMessageSize($response, 0)) ?: '-';
    }
911597
private static function checkResponse(Response $response)
    {
        $statusCode = $response->getStatusCode();

        if ($statusCode >= 400 && $statusCode < 600) {
            $reason = $response->getReasonPhrase();
            $body = json_decode($response->getBody());

            if (isset($body->error->exception[0]->message)) {
                $reason = $body->error->exception[0]->message;
            }

            throw new FenrirApiException($statusCode, $reason);
        }
    }
683651
protected function response(Response $response)
    {
        return $this->response->create(
            (string)$response->getContent(),
            $response->getStatusCode(),
            (array)$response->headers->all()
        );
    }
117135
private function handle(Response $response, $count = false)
    {
        $responseData = json_decode($response->getContent(), true);

        if (!$response->isSuccessful()) {
            // @todo get better error
            throw new \RuntimeException($response->getContent());
        }

        if (true === $count) {
            switch ($responseData['kind']) {
                case 'youtube#playlistItemListResponse':
                    return (int) $responseData['pageInfo']['totalResults'];
                    break;

                default:
                    throw new \Exception('unsupported count operation');
                    break;
            }
        }

        if (isset($responseData['nextPageToken'])) {
            $this->nextPageToken = $responseData['nextPageToken'];
        } else {
            $this->nextPageToken = null;
        }
        return $responseData['items'];
    }
592211
public function handle($input, IResponse $response = null) : int
    {
        if ($response === null) {
            $response = new ConsoleResponse(new Compiler(new Lexer(), new Parser()));
        }

        try {
            $request = $this->requestParser->parse($input);

            if ($this->isInvokingHelpCommand($request)) {
                // We are going to execute the help command
                $compiledCommand = $this->getCompiledHelpCommand($request);
            } elseif ($this->isInvokingVersionCommand($request)) {
                // We are going to execute the version command
                $compiledCommand = new VersionCommand($this->applicationVersion);
            } elseif ($this->commandCollection->has($request->getCommandName())) {
                // We are going to execute the command that was entered
                $command = $this->commandCollection->get($request->getCommandName());
                $compiledCommand = $this->commandCompiler->compile($command, $request);
            } else {
                // We are defaulting to the about command
                $compiledCommand = new AboutCommand($this->commandCollection, new PaddingFormatter(),
                    $this->applicationVersion);
            }

            $statusCode = $compiledCommand->execute($response);

            if ($statusCode === null) {
                return StatusCodes::OK;
            }

            return $statusCode;
        } catch (InvalidArgumentException $ex) {
            $response->writeln("<error>{$ex->getMessage()}</error>");

            return StatusCodes::ERROR;
        } catch (Exception $ex) {
            $response->writeln("<fatal>{$ex->getMessage()}</fatal>");

            return StatusCodes::FATAL;
        } catch (Throwable $ex) {
            $response->writeln("<fatal>{$ex->getMessage()}</fatal>");

            return StatusCodes::FATAL;
        }
    }
639710
public void addFriend(Friend friend) {
		try {
			get().addEntry(friend.get());
		} catch (NoResponseException | XMPPErrorException
				| NotConnectedException e) {
			e.printStackTrace();
		}
	}
1283900
public function handle($request, $response)
    {
        $this->response = $response;
        
        //$this->getSynopsis(true);
        $this->getSynopsis(false);
        
        $this->mergeConsoleDefinition();
        
        try {
            $request->bind($this->definition);
        } catch (\Exception $e) {
            if (!$this->ignoreValidationErrors) {
                throw $e;
            }
        }
        
        $this->beforeExecute($request, $response);
        
        if ($request->isInteractive()) {
            $this->interact($request, $response);
        }
        
        try {
            $request->validate();
        } catch (\Exception $e) {
            throw $e;
        }
        
        
        if ($this->code) {
            $statusCode = call_user_func($this->code, $request, $response);
        } else {
            $statusCode = $this->execute($request, $response);
        }
        
        return is_numeric($statusCode) ? (int) $statusCode : 0;
    }
472043
public function count_response($subpart, $try = 0) {
        $responseanalysisforclass = $this->get_response_class($subpart->responseclassid);
        $responseanalysisforclass->count_response($subpart->response, $subpart->fraction, $try);
    }