PHPDaemon\HTTPRequest\Generic::parseParams PHP Méthode

parseParams() protected méthode

Parses GET-query string and other request's headers
protected parseParams ( ) : void
Résultat void
    protected function parseParams()
    {
        if (!isset($this->attrs->server['HTTP_CONTENT_LENGTH'])) {
            $this->attrs->contentLength = 0;
        } else {
            $this->attrs->contentLength = (int) $this->attrs->server['HTTP_CONTENT_LENGTH'];
        }
        if (isset($this->attrs->server['CONTENT_TYPE']) && !isset($this->attrs->server['HTTP_CONTENT_TYPE'])) {
            $this->attrs->server['HTTP_CONTENT_TYPE'] = $this->attrs->server['CONTENT_TYPE'];
        }
        if (isset($this->attrs->server['QUERY_STRING'])) {
            self::parseStr($this->attrs->server['QUERY_STRING'], $this->attrs->get);
        }
        if (isset($this->attrs->server['REQUEST_METHOD']) && ($this->attrs->server['REQUEST_METHOD'] === 'POST' || $this->attrs->server['REQUEST_METHOD'] === 'PUT') && isset($this->attrs->server['HTTP_CONTENT_TYPE'])) {
            $this->attrs->server['REQUEST_METHOD_POST'] = true;
            self::parseStr($this->attrs->server['HTTP_CONTENT_TYPE'], $this->contype, true);
            $found = false;
            foreach ($this->contype as $k => $v) {
                if (mb_orig_strpos($k, '/') === false) {
                    continue;
                }
                if (!$found) {
                    $found = true;
                } else {
                    unset($this->contype[$k]);
                }
            }
            if (isset($this->contype['multipart/form-data']) && isset($this->contype['boundary'])) {
                $this->attrs->input->setBoundary($this->contype['boundary']);
            }
        } else {
            $this->attrs->server['REQUEST_METHOD_POST'] = false;
        }
        if (isset($this->attrs->server['HTTP_COOKIE'])) {
            self::parseStr($this->attrs->server['HTTP_COOKIE'], $this->attrs->cookie, true);
        }
        if (isset($this->attrs->server['HTTP_AUTHORIZATION'])) {
            $e = explode(' ', $this->attrs->server['HTTP_AUTHORIZATION'], 2);
            if ($e[0] === 'Basic' && isset($e[1])) {
                $e[1] = base64_decode($e[1]);
                $e = explode(':', $e[1], 2);
                if (isset($e[1])) {
                    list($this->attrs->server['PHP_AUTH_USER'], $this->attrs->server['PHP_AUTH_PW']) = $e;
                }
            }
        }
        $this->onParsedParams();
    }