解析Cookies
@param $request Swoole\Request
963389
function parseCookie(Swoole\Request $request)
    {
        $request->cookie = self::parseParams($request->header['Cookie']);
    }
346632
public function setRequest(Request $request)
    {
        $this->setParam('request', $request);
        $this->request = $request;
        return $this;
    }
207940
public function parse(Request $request)
    {
        if ($this->decrypt && $request->hasCookie($this->key)) {
            return Crypt::decrypt($request->cookie($this->key));
        }

        return $request->cookie($this->key);
    }
236372
protected function decrypt(Request $request)
	{
		foreach ($request->cookies as $key => $c)
		{
			try
			{
				$request->cookies->set($key, $this->decryptCookie($c));
			}
			catch (DecryptException $e)
			{
				$request->cookies->set($key, null);
			}
		}

		return $request;
	}
665397
private function _compatFPM(Request $request)
    {
        // Override php globals array
        // Store $_GET, $_POST ....
        $_GET    = $request->get ?? [];
        $_POST   = $request->post ?? [];
        $_COOKIE = $request->cookie ?? [];
        $_FILES  = $request->files ?? [];
        // $_REQUEST  = array_merge($_COOKIE, $_GET, $_POST);

        // 注入全局变量
        $GLOBALS['__$request']  = $request;
        $GLOBALS['__$DB_QUERY_COUNT'] = 0;

        // 兼容php-fpm的$_SERVER
        $_SERVER = [];
        foreach ($request->server as $key => $value) {
            $key = strtoupper($key);
            $_SERVER[$key] = $value;

            // FIXED: swoole REQUEST_URI don't contains QUERY_STRING
            if ($key === 'REQUEST_URI' && isset($_SERVER['QUERY_STRING'])) {
                $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
            }
        }

        // 兼容php-fpm的header传值
        foreach ($request->header as $key => $value) {
            $key = strtoupper(str_replace('-', '_', $key));
            if ($key === 'CONTENT_TYPE' || $key === 'CONTENT_LENGTH') {
                $_SERVER[$key] = $value;
            } else {
                $_SERVER['HTTP_' . $key] = $value;
            }
        }
    }
913593
function assign(Swoole\Request $request)
    {
        $_request = $this->getRequest();
        if (!empty($_request->get))
        {
            $request->get = $_request->get;
        }
        if (!empty($_request->post))
        {
            $request->post = $_request->post;
        }
        if (!empty($_request->files))
        {
            $request->files = $_request->files;
        }
        if (!empty($_request->cookie))
        {
            $request->cookie = $_request->cookie;
        }
        if (!empty($_request->server))
        {
            foreach ($_request->server as $key => $value)
            {
                $request->server[strtoupper($key)] = $value;
            }
            $request->remote_ip = $_request->server['remote_addr'];
        }
        $request->header = $_request->header;
        $request->setGlobal();
    }
1003278
public function setCookie(RequestCookie $cookie)
    {
        $this->cookies[$cookie->getName()] = $cookie;
        $this->setHeadersFromCookies();
    }
812217
protected function clean($request)
    {
        $this->cleanParameterBag($request->query);

        if ($request->isJson()) {
            $this->cleanParameterBag($request->json());
        } elseif ($request->request !== $request->query) {
            $this->cleanParameterBag($request->request);
        }
    }
184558
public function executeRequest(Request $request)
  {
    $curl = curl_init();

    if ($request->getPostBody()) {
      curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
    }

    $requestHeaders = $request->getRequestHeaders();
    if ($requestHeaders && is_array($requestHeaders)) {
      $curlHeaders = array();
      foreach ($requestHeaders as $k => $v) {
        $curlHeaders[] = "$k: $v";
      }
      curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
    }
    curl_setopt($curl, CURLOPT_URL, $request->getUrl());

    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
    curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());

    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);

    // The SSL version will be determined by the underlying library
    // @see https://github.com/google/google-api-php-client/pull/644
    //curl_setopt($curl, CURLOPT_SSLVERSION, 1);

    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, true);

    if ($request->canGzip()) {
      curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
    }
    
    $options = $this->client->getClassConfig('Curl', 'options');
    if (is_array($options)) {
      $this->setOptions($options);
    }
    
    foreach ($this->options as $key => $var) {
      curl_setopt($curl, $key, $var);
    }

    if (!isset($this->options[CURLOPT_CAINFO])) {
      curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem');
    }

    $this->client->getLogger()->debug(
        'cURL request',
        array(
            'url' => $request->getUrl(),
            'method' => $request->getRequestMethod(),
            'headers' => $requestHeaders,
            'body' => $request->getPostBody()
        )
    );

    $response = curl_exec($curl);
    if ($response === false) {
      $error = curl_error($curl);
      $code = curl_errno($curl);
      $map = $this->client->getClassConfig('Exception', 'retry_map');

      $this->client->getLogger()->error('cURL ' . $error);
      throw new Exception($error, $code, null, $map);
    }
    $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);

    list($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize);
    $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    $this->client->getLogger()->debug(
        'cURL response',
        array(
            'code' => $responseCode,
            'headers' => $responseHeaders,
            'body' => $responseBody,
        )
    );

    return array($responseBody, $responseHeaders, $responseCode);
  }
1224378
private function setLocale($locale, $request)
    {
        $allowedLangs = array_keys(Localizer::allowedLanguages());
        if (config('localizer.block_unallowed_langs') && !in_array($locale, $allowedLangs)) {
            abort(404, 'Unallowed language');
        }

        if (Auth::check()) {
            $user = Auth::User();
            $user->locale = $locale;
            $user->save();
        } else {
            $request->session()->put('locale', $locale);
        }
    }
171131
protected function startSession(Request $request)
    {
        $this->gc();
        $this->session->setId($request->getCookies()->get($this->session->getName()));
        $this->sessionHandler->open(null, $this->session->getName());
        $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId()));

        if ($sessionVars === false) {
            $sessionVars = [];
        }

        $this->session->start($sessionVars);
    }
422427
protected function executeRequest($request)
    {
        // 请求微信服务器
        $result = $this->request->curlPost($request->getRequestUrl(), $request->params());

        $result = (array)simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);

        return $result;
    }
1094707
public function read(Request $request)
    {
        if (!$request->cookies->has($this->cookieSettings->getName())) {
            return null;
        }

        return $this->createCookieWithValue(
            $request->cookies->get($this->cookieSettings->getName())
        );
    }
761921
public function run(&$request)
    {
        $this->detect($request);
        $request = $this->driver->formatIncomingRequest($request);
    }
906904
final public function setWebRequest(WebRequest $request)
    {
        if (self::$csrfValidation && $request->server('REQUEST_METHOD') == 'POST'){
            CsrfProtection::singleton()->validateHeaders($request);
            CsrfProtection::singleton()->validateCookie($request);
        }

        $this->request = $request;

        $this->parseRequest($request);
        $this->view->setWebRequest($request);

        $this->model->onAfterRequestSet();
        $this->onStateRestored();
    }
303854
public function setRequest(SimplifiedRequest $request)
    {
        if (!$this->element) {
            $this->setMatchElement($request->pathinfo);
        }

        parent::setRequest($request);
    }
438902
public function postRegister(Request $request)
    {
        $credentials = $request->only(['mobile', 'password']);

        $validator = Validator::make($credentials, [
            'mobile' => 'required', 'password' => 'required',
        ]);

        if ($validator->fails()) {
            return Redirect::back()->withInput()->withErrors($validator);
        }


        //这儿需要重写

        return Redirect::back()->withInput()->withErrors(['mobile' => $this->getFailedLoginMessage()]);
    }