22
33[ ![ Latest Stable Version] ( https://poser.pugx.org/corpus/http-message-utils/version )] ( https://packagist.org/packages/corpus/http-message-utils )
44[ ![ License] ( https://poser.pugx.org/corpus/http-message-utils/license )] ( https://packagist.org/packages/corpus/http-message-utils )
5- [ ![ Build Status ] ( https://github.com/CorpusPHP/HttpMessageUtils/workflows/CI/badge.svg? )] ( https://github.com/CorpusPHP/HttpMessageUtils/actions?query=workflow%3ACI )
5+ [ ![ CI ] ( https://github.com/CorpusPHP/HttpMessageUtils/workflows/CI/badge.svg? )] ( https://github.com/CorpusPHP/HttpMessageUtils/actions?query=workflow%3ACI )
66
77
88Utilities for working with [ PSR-7 Http Message] ( https://www.php-fig.org/psr/psr-7/ ) objects.
@@ -22,6 +22,97 @@ composer require 'corpus/http-message-utils'
2222
2323## Documentation
2424
25+ ### Class: \Corpus\HttpMessageUtils\Authorization\AuthorizationHeaderParser
26+
27+ Utility to split an Authorization header into ` <type> ` and ` <credentials> ` ala:
28+ ` Authorization: <type> <credentials> `
29+
30+ The parser itself is authorization type agnostic and works with any RFC7235
31+ conforming authorization type.
32+
33+ ### Example:
34+
35+ ``` php
36+ $serverRequest = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
37+ $parsedAuth = (new \Corpus\HttpMessageUtils\Authorization\AuthorizationHeaderParser)->parseServerRequest($serverRequest);
38+
39+ if( $parsedAuth ) {
40+ echo 'type: ' . $parsedAuth->getType();
41+ echo 'cred: ' . $parsedAuth->getCredentials();
42+ }
43+ ```
44+
45+ #### Method: AuthorizationHeaderParser->__ construct
46+
47+ ``` php
48+ function __construct([ ?\Corpus\HttpMessageUtils\Authorization\AuthorizationPartsFactory $factory = null])
49+ ```
50+
51+ ##### Parameters:
52+
53+ - *** \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsFactory*** | *** null*** ` $factory ` - Optional factory for construction of result objects
54+
55+ ---
56+
57+ #### Method: AuthorizationHeaderParser->parseString
58+
59+ ``` php
60+ function parseString(string $headerValue) : ?\Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface
61+ ```
62+
63+ Parses an Authorization header into ` <type> ` and ` <credentials> `
64+
65+ ##### Parameters:
66+
67+ - *** string*** ` $headerValue ` - The header value to parse
68+
69+ ##### Returns:
70+
71+ - *** \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface*** | *** null*** - AuthorizationParts on success, null on failure.
72+ Reasons for failure include empty string and non-RFC7235 compliant header values.
73+
74+ ---
75+
76+ #### Method: AuthorizationHeaderParser->parseServerRequest
77+
78+ ``` php
79+ function parseServerRequest(\Psr\Http\Message\ServerRequestInterface $request [, string $headerName = self::DEFAULT_HEADER]) : ?\Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface
80+ ```
81+
82+ Helper to easily parse from a PSR ServerRequestInterface
83+
84+ ##### Parameters:
85+
86+ - *** \Psr\Http\Message\ServerRequestInterface*** ` $request ` - The PSR ServerRequestInterface to read from
87+ - *** string*** ` $headerName ` - Optional header name to parse. Defaults to Authorization.
88+
89+ ##### Returns:
90+
91+ - *** \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface*** | *** null*** - AuthorizationParts on success, null on failure.
92+
93+ ### Class: \Corpus\HttpMessageUtils\Authorization\AuthorizationPartsInterface
94+
95+ Representation of the parts of an Authorization Header:
96+ ` Authorization: <type> <credentials> `
97+
98+ #### Method: AuthorizationPartsInterface->getType
99+
100+ ``` php
101+ function getType() : string
102+ ```
103+
104+ The specified authorization type
105+
106+ ---
107+
108+ #### Method: AuthorizationPartsInterface->getCredentials
109+
110+ ``` php
111+ function getCredentials() : string
112+ ```
113+
114+ The specified authorization credentials
115+
25116### Class: \Corpus\HttpMessageUtils\ProxyAwareSchemer
26117
27118Utility to map a Uri or ServerRequestInterface's Uri to the external scheme
0 commit comments