URI example

/** * Class URICast */
class URICast extends BaseCast
{
    /** * {@inheritDoc} */
    public static function get($value, array $params = []): URI
    {
        return $value instanceof URI ? $value : new URI($value);
    }
}
return $this;
    }

    /** * Set the controller's URI, with method chaining. * * @return mixed */
    public function withUri(string $uri)
    {
        $this->uri = new URI($uri);

        return $this;
    }

    /** * Set the method's body, with method chaining. * * @param string|null $body * * @return mixed */
    
public static function curlrequest(array $options = [], ?ResponseInterface $response = null, ?App $config = null, bool $getShared = true)
    {
        if ($getShared === true) {
            return static::getSharedInstance('curlrequest', $options$response$config);
        }

        $config ??= config(App::class);
        $response ??= new Response($config);

        return new CURLRequest(
            $config,
            new URI($options['base_uri'] ?? null),
            $response,
            $options
        );
    }

    /** * The Email class allows you to send email via mail, sendmail, SMTP. * * @param array|EmailConfig|null $config * * @return Email */

    public function __construct($config = null) // @phpstan-ignore-line     {
        if (empty($this->method)) {
            $this->method = $this->getServer('REQUEST_METHOD') ?? 'GET';
        }

        if (empty($this->uri)) {
            $this->uri = new URI();
        }
    }

    /** * Validate an IP address * * @param string $ip IP Address * @param string $which IP protocol: 'ipv4' or 'ipv6' * * @deprecated 4.0.5 Use Validation instead * * @codeCoverageIgnore */

    function previous_url(bool $returnObject = false)
    {
        // Grab from the session first, if we have it,         // since it's more reliable and safer.         // Otherwise, grab a sanitized version from $_SERVER.         $referer = $_SESSION['_ci_previous_url'] ?? Services::request()->getServer('HTTP_REFERER', FILTER_SANITIZE_URL);

        $referer ??= site_url('/');

        return $returnObject ? new URI($referer) : $referer;
    }
}

if (function_exists('uri_string')) {
    /** * URL String * * Returns the path part (relative to baseURL) of the current URL */
    function uri_string(): string
    {
        
/** * Downloads a file from the URI, and adds it to the file list. * * @param string $uri Because HTTP\URI is stringable it will still be accepted * * @return $this */
    final public function addUri(string $uri)
    {
        // Figure out a good filename (using URI strips queries and fragments)         $file = $this->getScratch() . basename((new URI($uri))->getPath());

        // Get the content and write it to the scratch space         write_file($fileservice('curlrequest')->get($uri)->getBody());

        return $this->addFile($file);
    }

    // --------------------------------------------------------------------     // Write Methods     // --------------------------------------------------------------------
    
return [$routePath$query$fragment];
    }

    private function determineBaseURL(
        App $configApp,
        ?string $host,
        ?string $scheme
    ): URI {
        $baseURL = $this->normalizeBaseURL($configApp);

        $uri = new URI($baseURL);

        // Update scheme         if ($scheme !== null && $scheme !== '') {
            $uri->setScheme($scheme);
        } elseif ($configApp->forceGlobalSecureRequests) {
            $uri->setScheme('https');
        }

        // Update host         if ($host !== null) {
            $uri->setHost($host);
        }
        if ($this->response instanceof DownloadResponse || $this->response instanceof RedirectResponse) {
            return;
        }

        // Ignore non-HTML responses         if (strpos($this->response->getHeaderLine('Content-Type'), 'text/html') === false) {
            return;
        }

        // This is mainly needed during testing...         if (is_string($uri)) {
            $uri = new URI($uri);
        }

        if (isset($_SESSION)) {
            $_SESSION['_ci_previous_url'] = URI::createURIString(
                $uri->getScheme(),
                $uri->getAuthority(),
                $uri->getPath(),
                $uri->getQuery(),
                $uri->getFragment()
            );
        }
    }

        return $this->call('options', $path$params);
    }

    /** * Setup a Request object to use so that CodeIgniter * won't try to auto-populate some of the items. */
    protected function setupRequest(string $method, ?string $path = null): IncomingRequest
    {
        $config = config(App::class);
        $uri    = new URI(rtrim($config->baseURL, '/') . '/' . trim($path, '/ '));

        $request      = new IncomingRequest($configclone $uri, null, new UserAgent());
        $request->uri = $uri;

        $request->setMethod($method);
        $request->setProtocolVersion('1.1');

        if ($config->forceGlobalSecureRequests) {
            $_SERVER['HTTPS'] = 'test';
        }

        
Home | Imprint | This part of the site doesn't use cookies.