Open Journal Systems  3.3.0
Symfony\Component\HttpFoundation\HeaderUtils Class Reference

Static Public Member Functions

static combine (array $parts)
 
static makeDisposition (string $disposition, string $filename, string $filenameFallback='')
 
static quote (string $s)
 
static split (string $header, string $separators)
 
static toString (array $assoc, string $separator)
 
static unquote (string $s)
 

Data Fields

const DISPOSITION_ATTACHMENT = 'attachment'
 
const DISPOSITION_INLINE = 'inline'
 

Detailed Description

HTTP header utility functions.

Author
Christian Schmidt githu.nosp@m.b@ch.nosp@m.sc.dk

Definition at line 19 of file HeaderUtils.php.

Member Function Documentation

◆ combine()

static Symfony\Component\HttpFoundation\HeaderUtils::combine ( array  $parts)
static

Combines an array of arrays into one associative array.

Each of the nested arrays should have one or two elements. The first value will be used as the keys in the associative array, and the second will be used as the values, or true if the nested array only contains one element. Array keys are lowercased.

Example:

HeaderUtils::combine([["foo", "abc"], ["bar"]])
// => ["foo" => "abc", "bar" => true]

Definition at line 83 of file HeaderUtils.php.

Referenced by Symfony\Component\HttpFoundation\AcceptHeaderItem\fromString(), Symfony\Component\HttpFoundation\Cookie\fromString(), Symfony\Component\HttpFoundation\AcceptHeader\fromString(), and Symfony\Component\HttpFoundation\HeaderBag\parseCacheControl().

◆ makeDisposition()

static Symfony\Component\HttpFoundation\HeaderUtils::makeDisposition ( string  $disposition,
string  $filename,
string  $filenameFallback = '' 
)
static

Generates a HTTP Content-Disposition field-value.

Parameters
string$dispositionOne of "inline" or "attachment"
string$filenameA unicode string
string$filenameFallbackA string containing only ASCII characters that is semantically equivalent to $filename. If the filename is already ASCII, it can be omitted, or just copied from $filename
Returns
string A string suitable for use as a Content-Disposition field-value
Exceptions

Definition at line 163 of file HeaderUtils.php.

References Symfony\Component\HttpFoundation\HeaderUtils\toString().

Referenced by Symfony\Component\HttpFoundation\ResponseHeaderBag\makeDisposition().

◆ quote()

static Symfony\Component\HttpFoundation\HeaderUtils::quote ( string  $s)
static

Encodes a string as a quoted string, if necessary.

If a string contains characters not allowed by the "token" construct in the HTTP specification, it is backslash-escaped and enclosed in quotes to match the "quoted-string" construct.

Definition at line 128 of file HeaderUtils.php.

Referenced by Symfony\Component\HttpFoundation\HeaderUtils\toString().

◆ split()

static Symfony\Component\HttpFoundation\HeaderUtils::split ( string  $header,
string  $separators 
)
static

Splits an HTTP header by one or more separators.

Example:

HeaderUtils::split("da, en-gb;q=0.8", ",;")
// => ['da'], ['en-gb', 'q=0.8']]
Parameters
string$separatorsList of characters to split on, ordered by precedence, e.g. ",", ";=", or ",;="
Returns
array Nested array with as many levels as there are characters in $separators

Definition at line 45 of file HeaderUtils.php.

Referenced by Symfony\Component\HttpFoundation\AcceptHeaderItem\fromString(), Symfony\Component\HttpFoundation\Cookie\fromString(), Symfony\Component\HttpFoundation\AcceptHeader\fromString(), Symfony\Component\HttpFoundation\HeaderBag\parseCacheControl(), and Symfony\Component\HttpFoundation\BinaryFileResponse\prepare().

◆ toString()

static Symfony\Component\HttpFoundation\HeaderUtils::toString ( array  $assoc,
string  $separator 
)
static

Joins an associative array into a string for use in an HTTP header.

The key and value of each entry are joined with "=", and all entries are joined with the specified separator and an additional space (for readability). Values are quoted if necessary.

Example:

HeaderUtils::toString(["foo" => "abc", "bar" => true, "baz" => "a b c"], ",")
// => 'foo=abc, bar, baz="a b c"'

Definition at line 107 of file HeaderUtils.php.

References Symfony\Component\HttpFoundation\HeaderUtils\quote().

Referenced by Symfony\Component\HttpFoundation\HeaderBag\getCacheControlHeader(), and Symfony\Component\HttpFoundation\HeaderUtils\makeDisposition().

◆ unquote()

static Symfony\Component\HttpFoundation\HeaderUtils::unquote ( string  $s)
static

Decodes a quoted string.

If passed an unquoted string that matches the "token" construct (as defined in the HTTP specification), it is passed through verbatimly.

Definition at line 143 of file HeaderUtils.php.

Field Documentation

◆ DISPOSITION_ATTACHMENT

const Symfony\Component\HttpFoundation\HeaderUtils::DISPOSITION_ATTACHMENT = 'attachment'

Definition at line 21 of file HeaderUtils.php.

◆ DISPOSITION_INLINE

const Symfony\Component\HttpFoundation\HeaderUtils::DISPOSITION_INLINE = 'inline'

Definition at line 22 of file HeaderUtils.php.


The documentation for this class was generated from the following file: