Overview
  • Namespace
  • Class

Namespaces

  • Slim
    • Exception
    • Handlers
      • Strategies
    • Http
    • Interfaces
      • Http

Classes

  • Body
  • Cookies
  • Environment
  • Headers
  • Message
  • Request
  • RequestBody
  • Response
  • Stream
  • UploadedFile
  • Uri

Class Headers

Headers

This class represents a collection of HTTP headers that is used in both the HTTP request and response objects. It also enables header name case-insensitivity when getting or setting a header value.

Each HTTP header can have multiple values. This class stores values into an array for each header name. When you request a header value, you receive an array of values for that header.

Slim\Collection implements Slim\Interfaces\CollectionInterface
Extended by Slim\Http\Headers implements Slim\Interfaces\Http\HeadersInterface
Namespace: Slim\Http
Located at Http/Headers.php

Methods summary

public static Slim\Http\Headers
# createFromEnvironment( Slim\Http\Environment $environment )

Create new headers collection with data extracted from the application Environment object

Create new headers collection with data extracted from the application Environment object

Parameters

$environment
The Slim application Environment

Returns

Slim\Http\Headers
public static Slim\Http\Environment
# determineAuthorization( Slim\Http\Environment $environment )

If HTTP_AUTHORIZATION does not exist tries to get it from getallheaders() when available.

If HTTP_AUTHORIZATION does not exist tries to get it from getallheaders() when available.

Parameters

$environment
The Slim application Environment

Returns

Slim\Http\Environment
public array
# all( )

Return array of HTTP header names and values. This method returns the original header name as specified by the end user.

Return array of HTTP header names and values. This method returns the original header name as specified by the end user.

Returns

array

Overrides

Slim\Collection::all

Implementation of

Slim\Interfaces\CollectionInterface::all()
public
# set( string $key, string $value )

Set HTTP header value

Set HTTP header value

This method sets a header value. It replaces any values that may already exist for the header name.

Parameters

$key
The case-insensitive header name
$value
The header value

Overrides

Slim\Collection::set

Implementation of

Slim\Interfaces\CollectionInterface::set()
public string[]
# get( string $key, mixed $default = null )

Get HTTP header value

Get HTTP header value

Parameters

$key
The case-insensitive header name
$default
The default value if key does not exist

Returns

string[]

Overrides

Slim\Collection::get

Implementation of

Slim\Interfaces\CollectionInterface::get()
public string
# getOriginalKey( string $key, mixed $default = null )

Get HTTP header key as originally specified

Get HTTP header key as originally specified

Parameters

$key
The case-insensitive header name
$default
The default value if key does not exist

Returns

string
public
# add( string $key, array|string $value )

Add HTTP header value

Add HTTP header value

This method appends a header value. Unlike the set() method, this method appends this new value to any values that already exist for this header name.

Parameters

$key
The case-insensitive header name
$value
The new header value(s)

Implementation of

Slim\Interfaces\Http\HeadersInterface::add()
public boolean
# has( string $key )

Does this collection have a given header?

Does this collection have a given header?

Parameters

$key
The case-insensitive header name

Returns

boolean

Overrides

Slim\Collection::has

Implementation of

Slim\Interfaces\CollectionInterface::has()
public
# remove( string $key )

Remove header from collection

Remove header from collection

Parameters

$key
The case-insensitive header name

Overrides

Slim\Collection::remove

Implementation of

Slim\Interfaces\CollectionInterface::remove()
public string
# normalizeKey( string $key )

Normalize header name

Normalize header name

This method transforms header names into a normalized form. This is how we enable case-insensitive header names in the other methods in this class.

Parameters

$key
The case-insensitive header name

Returns

string
Normalized header name

Implementation of

Slim\Interfaces\Http\HeadersInterface::normalizeKey()

Methods inherited from Slim\Collection

__construct(), clear(), count(), getIterator(), keys(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), replace()

Properties summary

protected static array $special

Special HTTP headers that do not have the "HTTP_" prefix

Special HTTP headers that do not have the "HTTP_" prefix

# [ 'CONTENT_TYPE' => 1, 'CONTENT_LENGTH' => 1, 'PHP_AUTH_USER' => 1, 'PHP_AUTH_PW' => 1, 'PHP_AUTH_DIGEST' => 1, 'AUTH_TYPE' => 1, ]

Properties inherited from Slim\Collection

$data

API documentation generated by ApiGen