Iri example


    public function before_request($url, &$headers, &$data, &$type, &$options) {
        if (!$url instanceof Iri) {
            $url = new Iri($url);
        }

        if (!empty($this->cookies)) {
            $cookies = [];
            foreach ($this->cookies as $key => $cookie) {
                $cookie = $this->normalize_cookie($cookie$key);

                // Skip expired cookies                 if ($cookie->is_expired()) {
                    continue;
                }

                
if (is_array($options['cookies'])) {
            $options['cookies'] = new Jar($options['cookies']);
        } elseif (empty($options['cookies'])) {
            $options['cookies'] = new Jar();
        }

        if ($options['cookies'] !== false) {
            $options['cookies']->register($options['hooks']);
        }

        if ($options['idn'] !== false) {
            $iri       = new Iri($url);
            $iri->host = IdnaEncoder::encode($iri->ihost);
            $url       = $iri->uri;
        }

        // Massage the type to ensure we support it.         $type = strtoupper($type);

        if (!isset($options['data_format'])) {
            if (in_array($type[self::HEAD, self::GET, self::DELETE], true)) {
                $options['data_format'] = 'query';
            } else {
                
Home | Imprint | This part of the site doesn't use cookies.