Download the PHP package corpus/http-message-utils without Composer
On this page you can find all versions of the php package corpus/http-message-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download corpus/http-message-utils
More information about corpus/http-message-utils
Files in corpus/http-message-utils
Package http-message-utils
Short Description Utilities for working with Psr7 Http Messages
License MIT
Informations about the package http-message-utils
HTTP Message Utils
Utilities for working with PSR-7 Http Message objects.
Requirements
- psr/http-message: ^1 || ^2
- php: >=7.3
Installing
Install the latest version with:
Documentation
Class: \Corpus\HttpMessageUtils\Authorization\AuthorizationHeaderParser
Utility to split an Authorization header into <type>
and <credentials>
ala:
Authorization: <type> <credentials>
The parser itself is authorization type agnostic and works with any RFC7235 conforming authorization type.
Example:
Method: AuthorizationHeaderParser->__construct
Parameters:
- \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsFactory | null
$factory
- Optional factory for construction of result objects
Method: AuthorizationHeaderParser->parseString
Parses an Authorization header into <type>
and <credentials>
Parameters:
- string
$headerValue
- The header value to parse
Returns:
- \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface | null - AuthorizationParts on success, null on failure. Reasons for failure include empty string and non-RFC7235 compliant header values.
Method: AuthorizationHeaderParser->parseServerRequest
Helper to easily parse from a PSR ServerRequestInterface
Parameters:
- \Psr\Http\Message\ServerRequestInterface
$request
- The PSR ServerRequestInterface to read from - string
$headerName
- Optional header name to parse. Defaults to Authorization.
Returns:
- \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface | null - AuthorizationParts on success, null on failure.
Class: \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface
Representation of the parts of an Authorization Header:
Authorization: <type> <credentials>
Method: AuthorizationPartsInterface->getType
The specified authorization type
Method: AuthorizationPartsInterface->getCredentials
The specified authorization credentials
Class: \Corpus\HttpMessageUtils\ProxyAwareSchemer
Utility to map a Uri or ServerRequestInterface's Uri to the external scheme detected from a proxy such as an AWS load balancer.
Will only ever upgrade to https, never downgrade.
Example:
Method: ProxyAwareSchemer->__construct
Parameters:
- array<string,scalar>
$server
- Server array to inspect. Defaults to $_SERVER. - array<string,string> | null
$proxyServerHttpsKeyValues
- Map of $_SERVER keys to their expected https-positive value. Defaults to ProxyAwareSchemer::HTTPS_EXPECTED_SERVER_VALUES - string[] | null
$proxyServerPortKeys
- Array of $_SERVER keys to check for a forwarded port value.
Method: ProxyAwareSchemer->withUriWithDetectedScheme
Given a \Psr\Http\Message\ServerRequestInterface returns a new instance of ServerRequestInterface with a new Uri
having the scheme adjusted to match the detected external scheme as defined by the proxies headers.
Parameters:
- bool
$detectPort
- Enable / Disable proxy port sniffing. - int | null
$defaultOnHttps
- Default port to use if sniffing fails but HTTPS proxy is detected. Defaults to ProxyAwareSchemer::REMOVE_PORT which removes the port information from the URI. Passing null will leave port as-is.
Method: ProxyAwareSchemer->withDetectedScheme
Given a \Psr\Http\Message\UriInterface returns an instance of UriInterface having the scheme adjusted to match
the detected external scheme as defined by the proxies headers.
Parameters:
- bool
$detectPort
- Enable / Disable proxy port sniffing. - int | null
$defaultOnHttps
- Default port to use if sniffing fails but HTTPS proxy is detected. Defaults to ProxyAwareSchemer::REMOVE_PORT which removes the port information from the URI. Passing null will leave port as-is.
Method: ProxyAwareSchemer->withDetectedPort
Given a \Psr\Http\Message\UriInterface returns an instance of UriInterface having the port adjusted to match
the detected external scheme as defined by the proxies headers.
Parameters:
- int | null
$default
- Defines a default fallback port. Passing ProxyAwareSchemer::REMOVE_PORT will default to removing the port information. Defaults to null - null leaves port as-is.
Class: \Corpus\HttpMessageUtils\ResponseSender
Utility to actualize a PSR7 ResponseInterface
Sends headers and body.
Example:
Inspired by http-interop/response-sender
MIT License Copyright (c) 2017 Woody Gilk
Method: ResponseSender->__construct
ResponseSender constructor.
Parameters:
- bool
$fullHttpStmtHeader
- Setting totrue
enables full HTTP statement construction which allows non-standard reason phrases and potentially mismatched protocol versions. Use with care. - bool
$rewindBody
- Setting tofalse
allows you to disable rewinding the body of the response before transmission.
Method: ResponseSender->send
Trigger the transmission of the given \Psr\Http\Message\ResponseInterface